multiple domains - single IP address - subdirectories -- .htaccess

Discussion in 'Server Operation' started by blinky, Dec 10, 2016.

  1. blinky

    blinky Member

    I have three domain names. All three have valid MX records and point to the same IP address.
    The primary domain sits (Ubuntu 16.04) in /var/www/html
    The secondary domain sits in /var/www/hmtl/fictitiousname
    The third domain sits in /var/www/html/bogusname
    I was able to get them working properly using the follow .htaccess file in the primary (var/www/html) directory:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?$
    RewriteRule !^fictitiusname/ fictitiousname%{REQUEST_URI} [L]
    RewriteCond %{HTTP_HOST} ^(www.)?$
    RewriteRule !^bogusname/ bogusname%{REQUEST_URI} [L]

    Now what I really want to do is to redirect ALL incoming traffic to use https rather than http. When I had a single primary domain this was easily accomplished using:
    RewriteEngine On
    # Redirect all HTTP traffic to HTTPS.
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
    What I want to do is have all traffic sent to its appropriate domain and subdirectory but also be done using https rather than http.
    This should be easy but I'm missing something...

Share This Page