subdomain redirect question

Discussion in 'Linux VPS/Dedicated - General' started by AlexH, May 10, 2014.

  1. AlexH

    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?
     
  2. esoft

    esoft New Member

    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.
     
  3. AlexH

    AlexH Member

    Perfect, thanks!
     

Share This Page