I use PHP.
A working htaccess-file
RewriteEngine On
RewriteBase /folder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .*[^/]$ $0/ [L,R=301]
RewriteCond $1 !^(index\.php)
RewriteRule ^(.+)$ index.php/$1 [L]
Look at the row with a # comment. When uncommented it adds a redirect to a slash. I use URL rewrite with toroPHP.
I want to rewrite to ending slash
- I want to redirect to ending slash from rewritten URLs, just like the code above.
- I don’t want ending slash from real files, like jquery.js, style.css.
Example (updated 2012-12-21)
/category/testshould be/category/test/http://www.test.com/myjsfile.jsshould behttp://www.test.com/myjsfile.js
Problem
- If I use the code above uncommented it add an ending slash to all urls, including javascript files and css files.
- I only want the rewritten urls to end with slash.
Question
Can it be done with htaccess? If so how?
The htaccess was almost correct. However the
REQUEST_FILENAMEneeds to be before EVERY rewrite rule, not just before the first.This works