[英]Removing trailing slashes with mod rewrite?
这与我之前的问题有关(可以在此处查看)。 我希望能够从网址中删除斜杠,以免混淆网站的某些区域。 .htaccess代码在这里:
# -s = File Exists
RewriteCond %{REQUEST_FILENAME} -s [OR]
# -l = Is a SymLink
RewriteCond %{REQUEST_FILENAME} -l [OR]
# -d = Is a Directory
RewriteCond %{REQUEST_FILENAME} -d
# if we match any of the above conditions - serve the file.
RewriteRule ^.*$ - [NC,L]
# only allows '.' in the "page" portion.
RewriteRule ^([^/.]+)/?$ index.php?section=$1 [L]
RewriteRule ^([^/.]+)/([^/]+)/?$ index.php?section=$1&page=$2 [L]
RewriteRule ^([^/.]+)/([^/]+)/([^/.]+)/?$ index.php?section=$1&page=$2&split=$3 [L]
和以前一样,我对此事还不了解,所以有人可以帮忙吗?
我假设您正在谈论规则:
RewriteRule ^.*$ - [NC,L]
由于另一个已经省略了斜杠。
尝试以下方法:
RewriteRule ^(.*)/$ $1 [NC,L]
这是我在日志中看到的(缩写):
applying pattern '^(.*)/$' to uri 'host/'
rewrite 'host/' -> 'host'
所以这对我来说似乎还可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.