您将需要进行一些更改。
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
#Code to add forward slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(?:\.\w+|/)$
RewriteRule (.*) $1/ [R,L]
#To check whether a .html appended string is a file existing on the system
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule (.*)/ $1.html [L]
#### NOT REQUIRED
#RewriteCond %{SCRIPT_FILENAME}/ -d
#RewriteCond %{SCRIPT_FILENAME}.html !-f
#RewriteRule [^/]$ %{REQUEST_URI}/ [R,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R,L]
这些规则也不会按预期工作:
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]+/$ %{REQUEST_URI}.html [QSA,L]
cos,%{REQUEST_URI}
总会有/
最后的。domain.com/about
如果请求类似 URI ,
它将被重写为:
domain.com/about/
最后到
domain.com/about/.html