When doing an apache rewrite for say mywebsite.com, and redirecting it to www.mywebsite.com I would have an issue where the new link would be http://www.mywebsite.com// and as such mywebsite.com/schedule.php would become www.mywebsite.com//schedule.php.
Before, the Rewrite was this:
RewriteCond %{HTTP_HOST} ^mywebsite\.com$
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301,L]
I changed the rewrite to the following to fix this:
RewriteCond %{HTTP_HOST} ^mywebsite\.com$
RewriteRule ^(([^/]+/)*)/+(.*)$ http://www.mywebsite.com/$1$3 [R=301,L]
Now the request mywebsite.com/schedule.php will be redirected to http://www.mywebsite.com/schedule.php
-Dravor
Subscribe to:
Post Comments (Atom)
1 comment:
This does not work for urls that look like http://example.com/go/to/this#comment
instead it redirects to
http://example.com/#comment
Post a Comment