我的.htaccess重写有一些非常奇怪的问题。
对于我测试的4页中的2页,重写工作,另外两页由于某种原因失败,并重定向到主页面(正如我的错误重写所期望的)。
我正在做的测试是确保删除所有带有.html的文件的扩展名,并确保有一个https连接。
我分别对它们进行测试,并将它们作为一对(重写/重定向到https以及删除.html)。只有当我试图重写这两种条件时,它们才会失败。
示例URL:
预期:
适用于"index.html“,但不适用于"about.html”。所有的页面都是简单的,一个词命名的页面,没有特殊的字符等等.
对于所有4页,我都以同样的方式重复了测试,但是对于2页,它们是有效的,而对于另外2页,它们不工作。
如果能提供一些帮助,谢谢!
RewriteEngine On
DirectoryIndex home.html home.php index.php index.html index.htm
ErrorDocument 404 www.WEBSITENAME.co
#Force ssl
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
#Ecwid rewrite
RewriteRule ^shop/.*$ shop [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]发布于 2017-07-13 09:48:18
看来我用下面的方法修复了它。我用旧代码尝试了L标志,但不知怎么的,它不起作用。也许我的缓存没有被清除。
#Force ssl
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.WEBSITENAME.co/$1 [R,L]https://stackoverflow.com/questions/45074819
复制相似问题