homepage Welcome to WebmasterWorld Guest from 54.204.182.118
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

    
www.example.com// to www.example.com/
mod_rewrite
defanjos

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4363086 posted 11:06 pm on Sep 15, 2011 (gmt 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

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4363086 posted 11:47 pm on Sep 15, 2011 (gmt 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.

lucy24

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



 
Msg#: 4363086 posted 12:38 am on Sep 16, 2011 (gmt 0)

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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4363086 posted 3:27 am on Sep 16, 2011 (gmt 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.

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