subdomain redirect question

AlexH

Member
Hello,

I have a subdomain (sub.domain.com), which has a SSL certificate installed. Because of the way subdomains are set up, I can still access the content at domain.com/sub

I would like to redirect all of the domain.com/sub traffic to https://sub.domain.com to ensure they are using the store with SSL.

I thought I would just redirect domain.com/sub traffic using a redirect, but it warned me that it would cause a loop.

What's the best way to handle this?
 
Hi,

You may use mod_rewrite.
i.e. add the following lines to your .htaccess (in subdomain root)

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
ensure to change the SERVER_NAME with your subdomain.

or you may use <VirtualHost>directives also.
 
Top