在我的网站上,我已经在域的非www版本上安装了SSL证书.我想使用htaccess将http www,http非www和https www重定向到
On my site I have installed an SSL certificate on the non www version of the domain. I would like to use htaccess to redirect http www, http non www and https www to
我可以将www改为非www,但是https www不会重定向到https non www.这是我的htaccess文件中的内容:
I have the www to non www working but the https www does not redirect to https non www. Here is what I have in my htaccess:
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ link [R=301,L] RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https link [R,L]有人可以帮我弄清楚我所缺少的吗?
Can anyone help me figure out what I am missing?
Sharon
推荐答案您可以使用:用于http或https,带或不带www-> https不带www
You can use: for http or https, with or without www -> https without www
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ %1%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} off RewriteRule ^ %{HTTP_HOST}%{REQUEST_URI} [R=301,L]反之:对于http或https,带或不带www-> 带有www的https
And for the opposite: for http or https, with or without www -> https with www
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} off RewriteRule ^ %{HTTP_HOST}%{REQUEST_URI} [R=301,L]更多推荐
使用htaccess将http://www,http://和https://www重定向到https:
发布评论