Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the trailing slash back in ExpressionEngine 2?

I have just upgraded from EE 1 to EE 2 and I am struggling with some of the changes. For example, the fact that EE no longer outputs a trailing slash on its urls is making a mess of a lot of my links where I had depended on constructions like EE generated url + additional segment. Finding and editing all places where I have done that would be a small nightmare considering the size and setup of my site. Is there any way to hack EE to get back the old behaviour?

like image 689
Linda Antonsson Avatar asked Nov 03 '12 21:11

Linda Antonsson


1 Answers

For some the trailing slash addition mentioned might cause conflicts with some forms. Adding the following to check if the request is a GET might be safer.

# Add a trailing slash to paths without an extension
RewriteCond %{THE_REQUEST} ^GET
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
like image 62
Parscale Avatar answered Sep 28 '22 12:09

Parscale