如何在特定的重写规则中添加尾部斜杠? htaccess的

时间:2014-10-05 19:58:22

标签: php .htaccess rewrite

如果在没有尾部斜杠的情况下加载页面,如何向此重写规则添加尾部斜杠?

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]

1 个答案:

答案 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]
相关问题