Ward
Ward

Reputation: 3318

Redirect Specific Page to HTTPS Using .htaccess

I'm trying to use .htaccess to redirect: http://shop.mysite.com/products/product-1 to https://shop.mysite.com/products/product-1 using .htaccess. The only difference is the last part of the URL, the product name. I only want the redirect to be in affect for the products pages, nothing else.

Any tips?

Upvotes: 0

Views: 872

Answers (1)

Jon Lin
Jon Lin

Reputation: 143966

Try adding these rules to the htaccess file in your document root:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^shop\.mysite\.com$ [NC]
RewriteRule ^/?products/(.*)$ https://%{HTTP_HOST}/products/$1 [L,R=301]

Upvotes: 2

Related Questions