I've spent a bit of time attempting different methods for adding trailing slashes to my URLs, such as this one:
On my production site, this is working fine with this rule:
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ /$1$2/ [R=301,L]
But it's not working on my local development setup. I run the local sites at localhost:9090
, so when I go to an URL such as localhost:9090/users/new/
I get a 500 Internal Server Error.
I've tried a similar rule using %{HTTP_POST}
and this doesn't work either. I feel like I'm missing something and searching the web keeps pointing me to rules I've already tried.
What is the best way to have a rule that works for both development and production?
NOTE
After some great advice from @anubhava, I reorganized my rules and found some better rules for existing needs. I ended up going with a new PHP extension rule and his recommendation and it's working now on both localhost
and production.