简体   繁体   English

.htaccess https重写错误重定向循环

[英].htaccess https rewrite error redirection loop

My .htaccess code giving me an error This webpage has a redirect loop in chrome browser. 我的.htaccess代码给我一个错误This webpage has a redirect loop在chrome浏览器中This webpage has a redirect loop

Can anyone correct my .htaccess code? 谁能纠正我的.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

If my website address is purchase.com.au and I need it to redirect to https://purchase.com.au 如果我的网站地址是Purchase.com.au,并且我需要将其重定向到https://purchase.com.au

Try this: 尝试这个:

RewriteCond %{HTTPS} off    
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Basically what it does is checkes if https is off (request was made via http - no https) and redirect every request to the https variant (same url just goes to https instead of http) 基本上,它的工作是检查https是否关闭(通过http发出请求-没有https),并将每个请求重定向到https变体(相同的URL只是转到https而不是http)

This may help you !! 这可能对您有帮助!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM