通过 htaccess 将所有 http 和 https 非 www URL 重定向到 https://www.xyz.com

编程入门 行业动态 更新时间:2024-10-24 08:32:15
本文介绍了通过 htaccess 将所有 http 和 https 非 www URL 重定向到 www.xyz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

由于太长和太复杂的原因(它涉及几层公司繁文缛节,导致其他人没有购买我请求的通配符 SSL 证书),我必须设置一个域来将所有请求重定向到 www.xyz – 使用 www 子域的安全协议.

For reasons much too long and complex to get into (it involves several layers of corporate red tape resulting in someone else not purchasing a wildcard SSL certificate I requested), I have to set up a domain to redirect all requests to www.xyz – secure protocol with the www subdomain.

所以:xyz、/www.xyz 和 xyz 都应该重定向到 www.xyz.

So: xyz, www.xyz, and xyz should ALL redirect to www.xyz.

我的 .htaccess-fu 充其量很弱,我似乎无法让它发挥作用.注意:如果这有所作为,则托管在 Media Temple 上.

My .htaccess-fu is weak at best and I can't seem to get this to work. Note: hosting is on Media Temple if that makes a difference.

到目前为止,我的 .htaccess 文件看起来像这样:

So far, my .htaccess file looks like so:

RewriteEngine On RewriteCond %{HTTPS} !^on$ RewriteRule (.*) www.xyz/$1 [R,L] RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ www.%{HTTP_HOST}/$1 [R=301,L]

xyz 和 www.xyz 正在重定向到 www.xyz,所以耶.但是,xyz不会重定向到 www.xyz 并因此抛出安全警告页面:

Both xyz and www.xyz are redirecting to www.xyz, so yay. However, xyz is not redirecting to www.xyz and is thus throwing a security warning page:

这可能不是您要找的网站!您试图访问 xyz,但实际上您访问了一个自称为 www.xyz 的服务器.这可能是由服务器上的错误配置或更严重的事情引起的.您网络上的攻击者可能会试图让您访问 xyz 的虚假(并且可能有害)版本.您不应继续,尤其是如果您之前从未见过此站点的此警告.

This is probably not the site you are looking for! You attempted to reach xyz, but instead you actually reached a server identifying itself as www.xyz. This may be caused by a misconfiguration on the server or by something more serious. An attacker on your network could be trying to get you to visit a fake (and potentially harmful) version of xyz. You should not proceed, especially if you have never seen this warning before for this site.

如果能帮助我度过最后的难关,我们将不胜感激!

Any help in getting me past this one final hump would be muchly appreciated!

推荐答案

如果未来有人(HELLO PEOPLE OF THE FUTURE)偶然发现这个问题,我问了同样的问题,并在 Server Fault 上得到了回答.

In case anyone from the future (HELLO PEOPLE OF THE FUTURE) stumble across this, I asked the same question and had it answered over at Server Fault.

>

简短版本:不可能.

Short version: impossible.

长版:serverfault/questions/523199/redirect-all-http-and-https-non-www-urls-to-https-www-example-com-via-htaccess

更多推荐

通过 htaccess 将所有 http 和 https 非 www URL 重定向到 https://www.xyz.com

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

发布评论

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

>www.elefans.com

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