通过htaccess的重定向所有的HTTP和HTTPS非www网址https://www.xyz.com [英] Redirect all http AND https non-www URLS to https://www.xyz.com via htaccess

查看:535
本文介绍了通过htaccess的重定向所有的HTTP和HTTPS非www网址https://www.xyz.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关原因,太漫长而复杂的进入(它涉及到企业的繁文缛节导致有人几层别人不购买一个通配符SSL证书,我要求),我必须建立一个域名重定向所有请求<一个HREF =htt​​ps://www.xyz.com相对=nofollow> https://www.xyz.com - 与安全协议的 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 https://www.xyz.com – secure protocol with the www subdomain.

所以: http://xyz.com ,的 http://www.xyz.com https://xyz.com 都应该重定向到 https://www.xyz.com

So: http://xyz.com, http://www.xyz.com, and https://xyz.com should ALL redirect to https://www.xyz.com.

我的.htaccess福弱充其量,我似乎无法得到这个工作。注:主机是对媒体寺如果有差别

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 (.*) https://www.xyz.com/$1 [R,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

http://xyz.com 和的 http://www.xyz.com 被重定向到 https://www.xyz .COM ,所以耶。然而, https://xyz.com 是的没有的重定向到的 https://www.xyz.com ,并因此引发安全警告页面:

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

这可能不是您要查找的网站!
  您试图访问 xyz.com ,但实际上访问的却一个服务器是标识为 www.xyz.com 。这可能是由在服务器上或通过一些更严重的问题导致。在网络上的攻击者可能正试图让您访问假冒(并且可能有害)的 xyz.com
  你不应该继续,特别是如果你从来没有见过这样的警告之前,这个网站。

This is probably not the site you are looking for!
You attempted to reach xyz.com, but instead you actually reached a server identifying itself as www.xyz.com. 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.com.
You should not proceed, especially if you have never seen this warning before for this site.

任何帮助,让我过去,这最后一个驼峰将长久AP preciated!

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

推荐答案

在从未来的情况下,任何人(HELLO未来人)偶然发现这个问题,我问同样的问题,把它回答了在服务器故障。

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.

短版:不可能

长版:<一href="http://serverfault.com/questions/523199/redirect-all-http-and-https-non-www-urls-to-https-www-example-com-via-htaccess">http://serverfault.com/questions/523199/redirect-all-http-and-https-non-www-urls-to-https-www-example-com-via-htaccess

这篇关于通过htaccess的重定向所有的HTTP和HTTPS非www网址https://www.xyz.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆