redirect non-www to www with ssl wildcard cert

Discussion in 'Installation/Configuration' started by sumawelt, Jan 12, 2015.

  1. sumawelt

    sumawelt New Member

    I run ISPConfig 3.0.5.4p5 on Debian Wheezy.
    There I have 3 Websites: cloud.example.com, wiki.example.com and www.example.com. Cloud.example.com is listed first in the list. All sites are ssl enabled and secured with a rapidssl wildcard certificate that covers my domain and all subdomains.
    At the redirect tab of www.example.com I have set a SEO Redirect domain.tld => www.domain.tld.
    Also for www.example.com, in the options tab in the field "Apache directives" I have the following code to force ssl for this site:
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    My aim is to redirect the sites http://example.com, https://example.com, http://www.example.com to https://www.example.com. This works fine for http://www.example.com, as it indeed redirects to https://www.example.com but when I cal http://example.com I always get redirected to cloud.example.com. Why does http://example.com redirect to my cloud and not to https://www.example.com as desired?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Apache will redirect to the first site in alphabet when it does not find a better matching vhost in its configuration files. Do all websits have a "auto subdomain" setting "www"?
     
  3. sumawelt

    sumawelt New Member

    No, none of them has. The are all set to Auto-Subdomain: None
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    A redirect can only match in a vhost that gets the traffic for a given domain or subdomain. so you have to add auto subdomain www if a redirect shall work for domain.tld and www.domain.tld. If no www subdomain exists, the firts vhost on the server, in your case the cloud vhost, will get the traffic.
     
  5. sumawelt

    sumawelt New Member

    Thanks a lot Till, setting auto subdomain to example.com did the trick. I tried this before but it did not work as exprected though. But now it does -who knows why :)
    Have a great day
     

Share This Page