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

   IT问题网   2018-11-15 00:00:00

问 题

有关原因,太漫长而复杂的进入(它涉及到企业的繁文缛节导致有人几层别人不购买一个通配符ssl证书,我要求),我必须建立一个域名重定向所有请求<一个href ="https://www.xyz.com"相对="nofollow"> https://www.xyz.com - 与安全协议的 www 子域。

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

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

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

rewriteengine叙述上
的rewritecond%{} https!^上$
重写规则(。*)https://www.xyz.com/$1 [r,l]

的rewritecond%{http_host}!^ www \。
(。*)重写规则^ $ 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 ,并因此引发安全警告页面:

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

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

解决方案

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

短版:不可能

长版:<一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

标签:通过定向有的以及网址



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

重定向的* .htm为* .PHP(Redirect *.htm to *.php)

problem i am trying find out how to redirect all traffic ...

HTTPS重定向到非www和http到www(Redirect https to non-www and http to www)

problem i searched and found hundreds of related cases, b ...

如何从URL使用htaccess的本地主机和主机服务器删除“/公众”?(how can remove &#39;/public&#39; from url using htaccess for localhost and host server)

problem i'm using zend framework 2 on xampp. i created .h ...

的.htaccess重写规则到路径不改变网址(.htaccess RewriteRule to path without changing URL)

problem so, i've this problem: base website located at ...

我怎样才能mod_rewrite的,并保持查询字符串?(How can I mod_rewrite and keep query strings)

problem i want to mod_rewrite a url to another page, but ...

如何从PHP脚本改变外观的URL(How to change appearance of URL from within a PHP script)

problem i have some php and html in the same file, and i ...

删除尾随的问号htaccess的(Removing trailing question mark with htaccess)

problem can someone help me understand this code # remov ...

URL重写GET参数(URL Rewrite GET parameters)

problem i want my url to look like the following www.web ...

htaccess的从XAMPP转向灯开的Ubuntu 13.10后不工作(启用htaccess的Apache中的Linux服务器)(htaccess is not working after moving from XAMPP to LAMP on ubuntu 13.10 (Enable htaccess in apache linux server))

problem my codeigniter project is running successfullyon ...

查询字符串和放大器;国防部重写(Query Strings &amp; Mod ReWrite)

problem i'm not too inexperienced with rewrite (not a mas ...

在.xml文件PHP的错误?(PHP error in .xml file)

problem ok firstly, i added this line to my .htaccess fil ...

使用Apache的mod_rewrite解析搜索引擎友好的URL(using apache&#39;s mod_rewrite to parse SEO friendly URL&#39;s)

problem how do i convert something like me.com/profile/2 ...

搜索引擎友好的URL(Search-Engine Friendly URLs)

problem i am working on building my first search-engine f ...

斜杠之后将文字与.htaccess的变量(Turn text after slashes into variables with HTACCESS)

problem i need to pass 3 variables with a url but using s ...

从URL删除字符与htaccess的(Remove Characters from URL with htaccess)

problem hopefully someone can see what i'm do ...

重定向所有的HTML扩展到.PHP(redirect all .html extensions to .php)

problem i want to update all the pages on a website to us ...

需要转义#(哈希/磅)字符在.htaccess重写规则(need to escape # (hash/pound) character in .htaccess rewrite rule)

problem the question is fairly simple but i w ...

如何使用的.htaccess重写规则改变下划线以破折号(How do I use .htaccess RewriteRule to change underscores to dashes)

problem i'm working on a site, and its cms used to save n ...

请求实体太大PHP(Request Entity Too Large PHP)

problem in one of my cakephp site, i got this error. req ...

的.htaccess使用PHP $ _GET缩短网址(.htaccess shorten URL using php $_GET)

problem i need to be able to shorten my page from: mydom ...