简体   繁体   English

将所有https请求重定向到http

[英]redirection all https requests to http

Small problem here, before changing my site to CMS, I have encountered a problem with redirecting all https:// requests to http:// . 这里的小问题,在将网站更改为CMS之前,我遇到了将所有https://请求重定向到http://

I have had the following in my .htaccess , which was doing all that 我的.htaccess包含以下内容,该内容已在执行所有操作

 RewriteCond %{SERVER_PORT} ^443$
 RewriteRule ^(.*)$ http://www.mysite.net/$1 [L,R=301]

but after changing it to CMS that requires different setup, I can no longer use the above mentioned code, since it does not do what it was intended to do in the first place. 但是在将其更改为需要不同设置的CMS之后,我将无法再使用上述代码,因为它起初并没有完成原本打算执行的操作。

Here is my current setup from .htaccess 这是我从.htaccess当前设置

 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-l
 RewriteRule ^(.*)$ index.php/$1 [QSA,L,NC]
 RewriteCond %{HTTP_HOST} !^(www\.)mysite\.net$ [NC]
 RewriteRule ^(.*)$ http://www.mysite.net/$1 [L,R=301]
 RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.net/.*$ [NC]
 RewriteRule \.(gif|jpg|png|tif|js|css|xls|xlsx|zip|rar|pdf|ods|ots)$ - [F]

Can you please advise me on how to do it all correctly, since I really do not want to double up all site content because of this problem and would rather redirect it all to the one consistent protocol. 您能为我提供有关如何正确完成所有操作的建议吗,因为由于这个问题,我真的不想将所有网站内容加倍,而是希望将所有内容重定向到一个一致的协议。

thanks in advance 提前致谢

Have your .htaccess like this: 让您的.htaccess像这样:

 RewriteEngine On
 RewriteBase /

 RewriteCond %{HTTP_HOST} !^www\. [NC]
 RewriteRule ^ http://www.mysite.net%{REQUEST_URI} [L,R=301,NE]

 RewriteCond %{HTTPS} on [OR]
 RewriteCond %{HTTP:X-Forwarded-Proto} https [OR]
 RewriteCond %{SERVER_PORT} ^443$
 RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

 RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.net/.*$ [NC]
 RewriteRule \.(gif|jpg|png|tif|js|css|xls|xlsx|zip|rar|pdf|ods|ots)$ - [F,NC]

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-l
 RewriteRule ^(.+)$ index.php/$1 [L]

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

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