我有一个非www URL的SSL证书: domain
I have a SSL certificate for non www URL: domain
我知道有很多类似的问题,但似乎没有一个能解决我的问题。这是我正在尝试做的事情:
I know there are many similar question, but none of them seems to solve my problem. Here is what I am trying to do:
问题:
1) www.domain -> domain **www to non www DONE** 2) domain -> domain **http to https DONE** 3) www.domain -> domain/ **NOT DONE** - Getting ERROR ON Above URL number (3): Your connection is not private到目前为止,我的.htaccess文件看起来像这样:
So far, my .htaccess file looks like so:
# www to non www RewriteCond %{HTTP_HOST} ^www\.domain\ [NC] RewriteRule (.*) domain/$1 [R=301,L] # http to https RewriteCond %{HTTPS} off RewriteRule .* %{HTTP_HOST}%{REQUEST_URI} [L,R=301] # www to htttps://请请注意,上面的.htaccess代码适用于我的第一个和第二个问题,现在我想解决我的第三个问题
Please note that above code of .htaccess is working fine for my first and second problem, Now I want to solve my third problem
以下是我的解决方案已经尝试过:
Here are the solutions that I already tried:
-
。htaccess使用SSL / HTTPS将www重定向到非www
htaccess强制https并将www重定向到非www,但没有其他子域
许多其他
推荐答案尝试一下:
将www重定向到非www(使用SSL时)
To redirect www to non-www (while using SSL)
RewriteCond %{HTTP_HOST} ^www.your_domain$ RewriteCond %{SERVER_PORT} ^443 RewriteRule ^(.*)$ your_domain/$1 [R=301]最后2个用于使用SSL或防止在某些页面上使用SSL时出现任何SSL错误。
The last 2 are meant for online stores using SSL or to prevent any SSL errors while using SSL on some pages.
Update1:
Update1:
RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{ENV:HTTPS} off RewriteRule ^ %{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ %1%{REQUEST_URI} [L,R=301,NE]更新2
在上使用RewriteEngine使所有http使用https:
RewriteEngine On Make all http use https:
RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ xxx.yyy/$1 [L,R=301]仅使www https使用非www https:
Make only www https use the non-www https:
RewriteCond %{SERVER_PORT} 443 RewriteCond %{HTTP_HOST} ^www[.].+$ RewriteRule ^(.*)$ xxxx.yyy/$1 [L,R=301]更新3:
在此处查看此问题:
。htaccess使用SSL / HTTPS将www重定向到非www
更多推荐
使用ssl / https将www重定向到非www的问题
发布评论