• Resolved chip902

    (@chip902)


    Hey all,

    First time poster. I have a rather what I like to think, “unique deployment” of WordPress. I have one server hosting 3 different sites; each with their own domain running https on Ubuntu with Apache 2.4.29. I have all 3 sites on their own apache conf file; each with its own /var/www/content directory at the /var/www/ level. The three sites are as follows in the order in which I installed them.

    https://liquorforlent.com
    https://christacyoga.com
    https://summit-estates.com

    My issue is if someone were to just type in “summit-estates.com” into an address bar, its constantly redirecting back to my first site, liquorforlent. If however you type in https://www.summit-estates.com it works fine. It will NOT work though if you do https://www.summit-estates.com; it will redirect back to liquorforlent. Is there something I’m missing in the .htaccess file or the apache config? I know there is something to do with non https but I don’t know how because I do not have any sites configured to run on port 80. I’m sure it’s something simple but I just can’t figure this out on my own. Happy to provide any additional config data. Let me know! TIA!

    • This topic was modified 5 years ago by chip902. Reason: adding https detail
    • This topic was modified 5 years ago by chip902.
    • This topic was modified 5 years ago by chip902.
    • This topic was modified 5 years ago by chip902. Reason: Made title more specific

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    In the VirtualHost configuration, server names are quite literal. A ‘www’ subdomain is not assumed. You can add ServerAlias directives to get Apache to recognize other subdomains or domains mapped to the same document root.

    You should have a separate virtual host configuration for each port to listen on. This is so the domain request goes to the right document root regardless of which port is used. This however will not change the requested protocol. To do that use a rewrite directive in .htaccess. There are a number of possible directives, this one is pretty common:

    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L,NE]

    Naturally you would change example.com to the proper domain name. Whether you use www or not is up to you, assuming you have the virtual host server names squared away.

    Thread Starter chip902

    (@chip902)

    Thanks @bcworkz but I literally just did this in my apache conf file for the virtual host and it worked…

    I had to add these lines BEFORE the module for <VirtualHost *:443>

    <VirtualHost *:80>
    ServerName summit-estates.com
    RedirectPermanent / https://www.summit-estates.com/
    </VirtualHost>

    This caught the random “what if” traffic coming in on Port 80 and made sure it gets tossed to the correct port WITH the correct virtual host. Problem solved by band aid! When in doubt, fix in production; that’s what I always say.

    Moderator bcworkz

    (@bcworkz)

    Cool! TIL about RedirectPermanent, thanks! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘3 WP Installs, 3 Domain Names, 1 Ubuntu Server’ is closed to new replies.