Problems doing a URL redirect in .htaccess

Discussion in 'Scripts' started by Nightshade, Nov 24, 2013.

to remove all ads.
  1. Nightshade

    Nightshade New Member

    I've tried dozens of different "solutions" and syntaxing (Redirect, RewriteCond, RewriteRule, Redirect 301, etc) and I just can't get this to work. I often get the "redirect loop" -error or the redirect doesn't work at all, or I get it working with only and not

    What I want to do:
    When the user goes to I want him or her redirected to
    And if the user goes to I want him or her redirected to as well
    ...and if the user goes to I want him or her redirected to

    ...and yea, I can only get one of these working at a time (or I get a loop).

    My .htaccess file without any redirects:
    # enable basic rewriting
    RewriteEngine on
    # enable symbolic links
    Options +FollowSymLinks
    # enable allowoverride privileges
    <Directory /www/replace/this/with/actual/directory>
     AllowOverride Options
    # do not allow anyone else to read your .htaccess file
    <Files .htaccess>
    deny from all
    # forbid viewing of directories
    Options All -Indexes
    # disable the server signature- helps with preformance
    ServerSignature Off
  2. chrishirst

    chrishirst Well-Known Member Staff Member

    Document fragment markers '#' are not passed to, or processed by the server. So trying to pass it in a redirect IS going to create a closed loop because site.tld#whatever IS the same as site.tld to an HTTP request.

    The browser processes the fragment marker, so that will have to be handled by javascript or by serverside code because both of those run after the http daemon has processed any htaccess directives and redirects.
  3. Nightshade

    Nightshade New Member

    Yea I ended up with a javascript solution, although I wanted to avoid that language as much as possible due to accessability. But my site is not dependent on it though so any users with jscript turned off will still be able to surf around without hassle. I think that is a fair solution.

Share This Page