2015-09-25 141 views
1

明白了与以下HTTPS重定向不工作

Redirect 301 /secure/test/ http://ww2.example.com/secure/test/ 
Redirect 301 /test/ http://ww2.example.com/test/ 
Redirect 301 /submission/ http://ww2.example.com/submission/ 

正常工作.htaccess文件这将愉快地重定向:

http://example.com/secure/test/login.aspx 

但是,如果有人进来对

https://example.com/secure/test/login.aspx 

它不起作用,我如何还重定向所有的https流量遵循上面的规则?

+0

你的'DocumentRoot'与'http'相同吗? – anubhava

回答

0

您需要将您的mod_alias重定向改为使用mod_rewrite。

例如,在.htaccess:

RewriteEngine 

RewriteCond %{SERVER_PROTOCOL} ^http(s?) [NC] 
RewriteRule ^(secure/test/.*) http%1://ww2.example.com/$1 [R=302,L] 

此重定向httphttphttpshttps。 (你确定你不要总想重定向到https呢?)

%1反向引用在匹配sSERVER_PROTOCOL(如果存在的话)。

测试前清除浏览器缓存(缓存301个重定向),并在确定工作正常时将302(临时)重定向更改为301(永久)。