homepage Welcome to WebmasterWorld Guest from 54.211.201.65
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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

Apache Web Server Forum

    
double 301
bull




msg:1525167
 6:24 am on May 26, 2006 (gmt 0)

I am currently doing a non-www redirect using

RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} !^localhost
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]
.

Alas, some folks have set links to a subdirectory of mine using http*//example.com/bar , but the correct canonical URL would be http*//www.example.com/bar/
So, currently, there is a double redirect
1) http*//example.com/bar => http*//www.example.com/bar
2) http*//www.example.com/bar => http*//www.example.com/bar/

Any simple way to get a single 301?

Cheers
bull

[edited by: jdMorgan at 3:26 pm (utc) on May 26, 2006]
[edit reason] example.com [/edit]

 

jdMorgan




msg:1525168
 3:24 pm on May 26, 2006 (gmt 0)

Sure, just fix /bar before the catch-all domain redirect:

RewriteRule ^bar$ http://www.example.com/bar/ [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com¦localhost)
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Replace the broken pipe "¦" character with a solid pipe character before use.

Jim

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