Remove trailing slash using redirect directive in vhost
Posted
by
Choy
on Server Fault
See other posts from Server Fault
or by Choy
Published on 2012-11-09T16:12:12Z
Indexed on
2012/11/09
17:04 UTC
Read the original article
Hit count: 259
I have an issue where urls that end in a "/" after a file name causes css/js to break.
I.e., http://www.mysite.com/index.php/ <-- breaks
http://www.mysite.com/ <-- OK, only breaks for file names
To fix, I tried adding a Redirect 301 directive in the vhost file as such where I'm checking to see if there's an extension with a slash after it:
<VirtualHost *:80>
ServerName mysite.com
Redirect 301 ^(.*?\..+)/$ http://mysite.com/$1
</VirtualHost>
The redirect appears to do nothing. Is this an issue with my implementation or is what I'm trying to accomplish not possible with a Redirect 301 in the vhost file?
© Server Fault or respective owner