Welcome to WebmasterWorld Guest from 54.242.173.65

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

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

mod_rewrite

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 12, 2002
posts:857
votes: 0


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
11:47 pm on Sept 15, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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.
12:38 am on Sept 16, 2011 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:13000
votes: 289


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.
3:27 am on Sept 16, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 12, 2002
posts:857
votes: 0


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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members