【发布时间】:2017-09-27 21:19:56
【问题描述】:
说实话,我很不熟悉.htaccess,但我想要完成的是:
所有http请求都重定向到https
所有页面都从 URL 中删除
.html
我有这个代码:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
但我在 Chrome 中不断收到错误消息:
example.com 重定向您的次数过多。
有什么想法吗?
【问题讨论】:
-
请举例说明您请求的网址。是否所有 URL 都通过简单地附加
.html直接映射到.html文件?尝试禁用MultiViews。 IE。Options -MultiViews在文件顶部。
标签: .htaccess