[英]add .htaccess trailing slash
I'd like to put a trailing slash to my url with .htaccess just in these 3 cases: 在这3种情况下,我想用.htaccess给我的网址添加一个斜杠:
?
最后一个斜杠后的部分不包含?
char 烧焦 .
最后一个斜杠后面的部分不包含.
char 烧焦 /
char 最后一个URL char不是/
char I'd like to add those rules to my existing .htaccess: 我想将这些规则添加到我现有的.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. 只需将其添加到现有文件中的RewriteEngine On
下面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.