homepage Welcome to WebmasterWorld Guest from 54.204.249.184
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 redirect problem 3 level "directory structure"
getoffmyisland




msg:4526841
 6:37 am on Dec 11, 2012 (gmt 0)

Hi,

I had to redirect about 60 pages like below:

Redirect 301 /property/randburg/r1-45952 http://www.example.com/residential/property/randburg
Redirect 301 /property/bryanston/b1-67706 http://www.example.com/residential/property/bryanston

Redirect 301 /property/illovo http://www.example.com/residential/property/illovo
Redirect 301 /property/broadacres-ah http://www.example.com/residential/property/broadacres

But when i visit this link on the old domain:

http://www.example.com/property/randburg/r1-45952

..it redirects to
http://www.example.com/residential/property/randburg/r1-45952

It adds this at the end: /r1-45952

It only happens with url with characters similar to /r1-45952 at the end, all other redirects work fine.

I've tried organizing the 301 redirects to most specific first, most general last

But I'm still experiencing the problem.

Any fix for this ?

 

lucy24




msg:4526852
 7:41 am on Dec 11, 2012 (gmt 0)

http://www.example.com/property/randburg/r1-45952

..it redirects to
http://www.example.com/residential/property/randburg/r1-45952

Key difference between mod_rewrite (RewriteRule, which can make a redirect) and mod_alias (Redirect by that name): mod_alias reappends the rest of the path.

Somewhere you've got a rule that redirects

http://www.example.com/property/
to
http://www.example.com/residential/property/

or possibly

http://www.example.com/property/pottersfalls/
to
http://www.example.com/residential/property/pottersfalls/

Anything that originally came after /property/ will be reattached after /property/ in the redirect.

Solution is to change everything from mod_alias to mod_rewrite. If you've got a text editor that does Regular Expressions, you can do it all in a couple of global search-and-replace operations.

You'll never look back ;)

g1smd




msg:4526882
 10:18 am on Dec 11, 2012 (gmt 0)

Use RewriteRule configured as a 301 redirect for all of your rules. Make sure the rule target includes both protocol and hostname.

Make sure your non-www/www canonicalisation redirect is last in the list.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved