Welcome to WebmasterWorld Guest from 23.21.38.201

Forum Moderators: Ocean10000 & incrediBILL & phranque

double 301

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

10+ Year Member



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]

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month