Get the most out of your Centmin Mod LEMP stack
Become a Member

Domains How to Park domain on top of another (domain aliases) ?

Discussion in 'Domains, DNS, Email & SSL Certificates' started by eva2000, Aug 6, 2016.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    30,947
    6,915
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,413
    Local Time:
    8:54 AM
    Nginx 1.13.x
    MariaDB 5.5

    DNS Domain Parking



    First step is at DNS level, ensure you domains point to same server IP address for both live domain and domain to be parked. You may need up to 24-48hrs to see domain propagation and can use online too at whatsmydns.net to check your domains DNS A records.

    Nginx Domain Parking/Alias



    Then, you basically edit the domain's nginx vhost /usr/local/nginx/conf/conf.d/domain.com.conf file and/or /usr/local/nginx/conf/conf.d/domain.com.ssl.conf if it exists and edit the server_name listing so if abc.com was real live site and xyz.com is the domain your want to park on top of abc.com as domain alias, it would be
    Code (Text):
    server {
    server_name abc.com xyz.com;

    If you need www too it would be
    Code (Text):
    server {
    server_name abc.com www.abc.com xyz.com www.xyz.com;

    Then to ensure your SEO isn't messed up setup canonical link headers in nginx vhost file too as outlined here. You need to set it up in 2 places.

    In nginx vhost file itself i.e. /usr/local/nginx/conf/conf.d/abc.com.conf or /usr/local/nginx/conf/conf.d/domain.com.conf and if applicable /usr/local/nginx/conf/conf.d/abc.com.ssl.conf or /usr/local/nginx/conf/conf.d/domain.com.ssl.conf
    Code (Text):
    add_header Link "<http://abc.com$request_uri>; rel=\"canonical\"";
    

    and in /usr/local/nginx/conf/staticfiles.conf include file which is included in each nginx vhost file. Add header canonical link to the html location context
    Code (Text):
        location ~* \.(html|htm|txt)$ {
      add_header Link "<http://abc.com$request_uri>; rel=\"canonical\"";
      #add_header Pragma public;
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        expires 1d;
        break;
            }
    

    This is so that html based files also serve the correct canonical link header to tell search engines which is the real domain so that search engines do not see it as duplicate content.

    Then restart Nginx and PHP-FPM at same time using Centmin Mod command shortcuts outlined in FAQ item 15
    Code (Text):
    nprestart
    

    To confirm just run curl command in SSH against your domain i.e. curl headers and grep filter for word canonical
    Code (Text):
    curl -sI https://abc.com | grep canonical
    

    output would be something like
    Code (Text):
    curl -sI https://abc.com | grep canonical
    Link: <http://abc.com/>; rel="canonical"
    

     
Thread Status:
Not open for further replies.