Welcome to WebmasterWorld Guest from 54.145.44.134

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

www.example.com// to www.example.com/

mod_rewrite

     

defanjos

11:06 pm on Sep 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've looked online, but can't seem to find a mod_rewrite 301 redirect example for:

www.example.com// to www.example.com/

Can someone help?
Thanks

g1smd

11:47 pm on Sep 15, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



This "may" work.

RewriteRule ^/(.*) http://www.example.com/$1 [R=301,L]


If it does not, then some solution using an additional preceding RewriteCond looking at THE_REQUEST may be in order.

lucy24

12:38 am on Sep 16, 2011 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



The removed prefix always ends with a slash, meaning the matching occurs against a string which never has a leading slash. Therefore, a Pattern with ^/ never matches in per-directory context.

Make that "never unless you're getting stuck with severely malformed URLs" ;) The writers of the Apache docs forgot the part about how it's impossible to make things foolproof because fools are so ### ingenious.

Tangential but not irrelevant: Do you have any information on where these // are coming from? Is it in your power to do anything about it? They seem to have hit on the only possible permutation of / and . that isn't auto-repaired in transit.

defanjos

3:27 am on Sep 16, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have any information on where these // are coming from?


Yes, there is a very valuable link that is linking to me with //.
I have the canonical url in place, but want to make absolute sure I am not losing the link juice from that site.
It may be others also - this is not the first time I see people making that mistake when linking.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month