使用htaccess将http://www,http://和https://www重定向到https:

编程入门 行业动态 更新时间:2024-10-21 18:29:57
本文介绍了使用htaccess将www,和www重定向到https:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的网站上,我已经在域的非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:

本文发布于:2023-10-31 15:53:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546557.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   http   htaccess   https   www

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!