我的.htaccess
代码在Chrome浏览器中显示错误This webpage has a redirect loop
。
任何人都可以更正我的.htaccess
代码吗?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^purchase\.com\.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.purchase\.com\.au$
RewriteRule ^(.*)$ "https\:\/\/purchase\.com\.au\/$1" [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
DirectoryIndex index.html index.php
如果我的网站地址是purchase.com.au,我需要将其重定向到https://purchase.com.au
答案 0 :(得分:3)
试试这个:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
它的作用基本上是检查https是否已关闭(请求是通过http - 无https进行的)并将每个请求重定向到https变体(相同的网址只是转到https而不是http)
答案 1 :(得分:0)
这可能对你有所帮助!!
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://purchase.com.au/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://purchase.com.au/$1 [L,R=301]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
DirectoryIndex index.html index.php