mod_rewrite and double slash issue
RewriteRule ^\/?(.*)$ http://www.example.com/$1 [R=301,L]
Putting a slash into your pattern should resolve this issue:
RewriteRule ^/(.*)$ http://www.example.com/$1 [R=301,L]
Actually, you will always have double slashes due to
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
combined with the fact that REQUEST_URI (that you are matching on) normally contains a starting slash. What you can try is RewriteRule ^(.*)$ http://example.com$1
, and then send a broken HTTP request GET foo HTTP/1.0
and see if Apache deals with it properly.
Fixed with:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
because $1
by default contains the index path /