如果在没有尾部斜杠的情况下加载页面,如何向此重写规则添加尾部斜杠?
Options -MultiViews
RewriteEngine On
RewriteBase /project/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
答案 0 :(得分:0)
将规则更改为:
Options -MultiViews
RewriteEngine On
RewriteBase /project/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*[^/])$ %{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)?$ index.php?url=$1 [QSA,L]