Redirecting question (2 posts)

  1. Jem
    Posted 11 years ago #


    This is slightly OT, I know, but I haven't had much luck finding help elsewhere...

    For some reason, a lot of links come into my blog from http://www.higgs-family.net/%7ejeremy/... instead of http://www.higgs-family.net/~jeremy/... (which is how it's setup in the options). As a result, I get a whole ton of incorrect referrer tags from people who have come in through the %7e link.

    I've been trying to create a RewriteRule that will do this, but haven't had much luck...

    I've added the following to a .htaccess file at the base of the document root (for http://www.higgs-family.net/):

    RewriteEngine On
    RewriteBase /

    RewriteRule ^/%7ejeremy/?$ http://www.higgs-family.net/~jeremy/$1 [R=permanent]

    ... however, it does nothing. I also tried:

    RewriteRule ^/$ http://www.higgs-family.net/~jeremy/ [R]

    ... but it did nothing, too. Redirects ARE working, as I have a .htaccess in the ~jeremy directory.

    Any suggestions?

    Thanks for any help!

  2. Mark McKibben
    Posted 11 years ago #

    I've not had this problem (and have never needed to hand-craft my rewrite rules), but some googling lead me to this site, which says:

    An easier RedirectMatch command...
    RedirectMatch permanent ^/([-¸·{|}´'"+*^¯¨¬\\]|''||\^\^)(.*)$

    ... and more complex, but much better set of RewriteRules (needs mod_rewrite):
    # Part a: URL does not end with "/"
    RewriteCond" rel="nofollow">http://www.domain.com/~$2'"+*^¯¨¬\]|''|RewriteCond
    /var/htdocs/$1$2 !-d
    RewriteCond /var/htdocs/$1$2 !-f
    RewriteCond /~$2 -U
    RewriteRule ^/([-¸·{|}´|^^)(/?([^/]+)(/.*[^/])?)?$ http://www.domain.com/~$2 [R=permanent,L]RewriteCond /var/htdocs/$1$2 !-d
    RewriteCond /~$2 -U
    RewriteRule ^/([-¸·{|}´

    # Part b: URL ends with "/"
    '"+*^¯¨¬\\]|''||\^\^)(/?([^/]+)(/.+)?/)?$ http://www.domain.com/~$2 [R=permanent,L]`

    Hopefully that helps you out.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.