htaccess - 仅将子域http重定向到https

时间:2014-02-06 15:30:30

标签: apache url-rewrite-module

我想将http重定向到https,只在一个子域下使用.htaccess rewrite_mod页面。

例如:仅适用于此子域: http://www.test.com/product/

http ://www.test.com/product/good1/至 https ://www.test.com/product/good1/

http ://www.test.com/product/good2/转到 https ://www.test.com/product/good2/

问题是:有可能吗?如果是的话,你能举个例子吗?

感谢

2 个答案:

答案 0 :(得分:0)

尝试此规则

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^/product [NC]
RewriteRule ^ https://www.test.com%{REQUEST_URI} [R=301,L]

答案 1 :(得分:0)

试试这个,

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www.test.com$
RewriteCond %{REQUEST_URI} ^/product/(.*)$
RewriteRule ^(.*)$ https://www.test.com/$1 [L,R=301]