Reputation: 165
I'd like to put a trailing slash to my url with .htaccess just in these 3 cases:
?
char.
char/
charI'd like to add those rules to my existing .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [NC,L]
RewriteRule ^.* index.php [NC,L]
Upvotes: 1
Views: 299
Reputation: 16825
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^((.*/)?[^/\.]+)$ /$1/ [R,L]
Upvotes: 3
Reputation: 865
RewriteRule ^(.*?[^/\?\.])$ http://example.com/$1/ [L]
Should do what you're looking for. Just add it right below RewriteEngine On
in your existing file.
Upvotes: 0