I'd like to put a trailing slash to my url with .htaccess just in these 3 cases:
?
char .
char /
char I'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]
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^((.*/)?[^/\.]+)$ /$1/ [R,L]
RewriteRule ^(.*?[^/\?\.])$ http://example.com/$1/ [L]
Should do what you're looking for. Just add it right below RewriteEngine On
in your existing file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.