使用ssl / https将www重定向到非www的问题

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

我有一个非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的问题

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

发布评论

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

>www.elefans.com

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