I’m trying to get a bit of .htaccess code that will add a forward trailing slash on the end of a URL if it has not got one already but can’t seem to crack it.
I’ve tried
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [L,R=301]
Any tips?
Thanks
Your condition says to only apply this rule if the URL matches a physical directory; was that your intent?
Hi I’m using URL’s pulled from the database so they are not physical directories.
I’ve also tried
RewriteCond %{REQUEST_URI} -d
RewriteRule ^(.+[^/])$ $1/ [L,R=301]
I just want to put a back slash on a link if one hasn’t been put in.
such as http://webaddress.com:8080/example-link
shoud turn to http://webaddress.com:8080/example-link/
dklynn
October 26, 2010, 10:17am
4
m&h,
IMHO, that’s a dumb thing to do:
It changes the directory level and, thus, the relative links within your scripts.
It forces you to use Options +MultiViews which confuses visitors (okay, maybe that’s just me)
It adds a superfluous character for no good reason.
Just WHY do you think this is a smart thing to do, if you please?
Regards,
DK