0

抱歉,但我对 URL 重写相当陌生。我已经设法让重写在传统意义上工作,但不能强迫它有一个斜杠。

这是代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /$1.html [L,QSA]
4

1 回答 1

0

你可以试试:

RewriteEngine On
RewriteBase /

# add a trailing slash for non-files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)/?$ $1.html [L]
于 2015-04-01T16:34:03.820 回答