.htaccess rule: multiple domains to one ssl domain

烈酒焚心 提交于 2020-01-03 00:56:10

问题


I've tried around getting the following to work for 2 hours now.

I have multiple domains such as: Test.Xy.zz Test.Abc.de Test.mmm.mm

Now only Test.xy.zz got an ssl certificate and the application running on it is limited to it. Therfor I want all non-ssl requests - including test.xy.zz and all other domains to go to https://test.xy.zz

Hope someone can help.

Possible solution:

RewriteEngine On

RewriteCond %{HTTP_HOST} !test\.xy\.zz
RewriteRule ^(.*) https://test.xy.zz/$1 [QSA,R=301]

RewriteCond %{HTTPS} !on
RewriteRule ^(.*) https://test.xy.zz/$1 [QSA,R=301]

Hope this helps anyone.


回答1:


 RewriteCond %{HTTPS} !on [OR]
 RewriteCond %{HTTP_HOST} !^test.xy.zz$
 RewriteRule (.*) https://test.xy.zz$1 [QSA,R=301]


来源:https://stackoverflow.com/questions/15212134/htaccess-rule-multiple-domains-to-one-ssl-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!