简体   繁体   English

HTTP到HTTPS-重定向过多

[英]HTTP to HTTPS - Too many redirects

I have a site with Wordpress. 我有一个Wordpress网站。 I need some single page to redirect HTTPS 我需要一些页面来重定向HTTPS

I get code form stackoverflow and put in .htaccess 我得到代码形式stackoverflow并放入.htaccess

        # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTPS} off
    RewriteCond %{THE_REQUEST} /online-order-auto [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

    RewriteCond %{HTTPS} on
    RewriteCond %{THE_REQUEST} !/online-order-auto [NC]
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

    RewriteRule ^index\.php$ - [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    RewriteCond %{HTTP_HOST} ^(www\.)?site\.com\.swtest\.ru$
    RewriteRule ^(.*)$ http://www.site.ru/$1 [L,R=301]

The browser wrote "ERR_TOO_MANY_REDIRECTS". 浏览器写了“ ERR_TOO_MANY_REDIRECTS”。 I cant understand whats a problem 我不明白有什么问题

Try this. 尝试这个。 I've been looking all over and this is the only way I could make it work... 我一直在寻找,这是我可以使其运作的唯一途径...

#non-www. http to www. https
RewriteCond %{ENV:HTTPS} !on
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com$
RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]

#non-www. https to www. https
RewriteCond %{ENV:HTTPS} on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$
RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]

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

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