Question

I want to redirect http to https with .htaccess rewrite_mod only pages under one subdomain.

for example: only for this sub domain: http://www.test.com/product/

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

from http://www.test.com/product/good2/ to https://www.test.com/product/good2/

the question is: is it possible? if yes, could you give me one example?

thanks

Was it helpful?

Solution

Try this rule

RewriteEngine On
RewriteBase /

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

OTHER TIPS

Try this,

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www.test.com$
RewriteCond %{REQUEST_URI} ^/product/(.*)$
RewriteRule ^(.*)$ https://www.test.com/$1 [L,R=301] 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top