<Directory /var/www/html/>
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L]
</Directory>
如何修改上述.htaccess规则,在网址后添加/
但不会破坏现有的RewriteRule?
我尝试简单追加:RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
,但这不起作用。
答案 0 :(得分:1)
只检查URI是否以/结尾,如果没有,则添加一个URI。
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]