double slash apache configuration
Posted
by VP
on Stack Overflow
See other posts from Stack Overflow
or by VP
Published on 2010-03-14T11:25:11Z
Indexed on
2010/03/14
11:35 UTC
Read the original article
Hit count: 276
Hi, i'm deploying a ror application and now i have to rewrite the url (in apache) to
- add a prefix www to the url
- add / to the end of the url
So i took the following approach:
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteCond %{HTTP_HOST} ^foo\.com
RewriteRule ^(.*)$ http://www.foo.com/$1 [R=301,L]
The problem is that it is appending two trailing slash to my url So for example a resource /question/ask are becoming:
http://foo.com//question/ask
I tried to add the following Rule before all my Rewrite rules to try to remove the double //:
RewriteCond %{REQUEST_URI} ^//
RewriteRule ([^/]*)/+(.*) http://www.foo.com/$1/$2 [R=301,L]
but it didnt work.. any idea to rip off all extras "//" added to the url?
© Stack Overflow or respective owner