htaccess的重定向非www到www,而preserving HTTP和放大器; HTTPS放大器、重定向、www、htaccess

由网友(懒得看女孩掉眼泪)分享简介:我的网站刚刚得到的EV SSL证书。在过去,我已经重定向非www请求,WWW使用htaccess的 - 和它的工作好My site just got its EV SSL certificate. In the past I've redirected non-www requests to www using h...

我的网站刚刚得到的EV SSL证书。在过去,我已经重定向非www请求,WWW使用htaccess的 - 和它的工作好

My site just got its EV SSL certificate. In the past I've redirected non-www requests to www using htaccess - and it worked well.

但现在,如果我要求一个HTTPS页面,我结束了(通过htaccess的重定向)的HTTP版本。

But now, if I request a https page, I end up (via the htaccess redirect) on the http version.

我需要htaccess的重定向是这样的:非www重定向到www,而preserving HTTP或HTTPS

I need htaccess to redirect like this: non-www redirects to www, while preserving the http or https

下面是我用现在的htaccess文件:

Here is the htaccess file I'm using now:

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

这是不工作的权利。该HTTPS请求将被重定向到HTTP。

It isn't working right. The https requests are being redirected to http.

推荐答案

试试这个:

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+.[^.]+$
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301,QSA]
RewriteCond %{HTTP_HOST} ^[^.]+.[^.]+$
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301,QSA]
阅读全文

相关推荐

最新文章