问题描述
有关原因,太漫长而复杂的进入(它涉及到企业的繁文缛节导致有人几层别人不购买一个通配符SSL证书,我要求),我必须建立一个域名重定向所有请求 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 ,的和 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 和的被重定向到 https://www.xyz .COM ,所以耶。然而, https://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 。
你不应该继续,特别是如果你从来没有见过这样的警告之前,这个网站。
任何帮助,让我过去,这最后一个驼峰将长久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.
短版:不可能
长版: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!