【发布时间】:2016-05-25 17:28:46
【问题描述】:
我的网站的 .htaccess 文件有点问题。我想让 page.html 和 page/ URL 都重定向到没有任何后缀的页面。我已经能够关闭 .html,但是在输入页面/ URL 时,无论我尝试什么(Apache 2.4.18)都会出现内部服务器错误。
这是完整的 .htaccess 代码(没有任何删除尾部斜杠的尝试)
Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.website.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
我想做的只是复制适用于 .html 的最后 6 行,但让它作用于尾部斜杠,但我不知道该怎么做,或者是否有更好的解决方案。非常感谢任何建议!
【问题讨论】:
标签: apache .htaccess redirect trailing-slash