Discover Centmin Mod today
Register Now

Install change the domain

Discussion in 'Install & Upgrades or Pre-Install Questions' started by dooma, Dec 8, 2016.

  1. dooma

    dooma Member

    226
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    11:39 AM
    Hi,

    I wanna change the domain of my website to avoid installing everything again ?, can I do that ?

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,196
    6,789
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,144
    Local Time:
    7:39 PM
    Nginx 1.13.x
    MariaDB 5.5

    Changing Site's Domain Name



    Like http to https redirects you do one for switching domains. Example where domain.us is old domain and domain.com is new domain for site. You do a domain.us to domain.com redirect as outlined at How to Create NGINX Rewrite Rules | NGINX
    1. setup a new nginx vhost for new domain.com and DNS A record point to same server IP as domain.us
    2. grab your domain.us.conf and/or domain.us.ssl.conf nginx vhost and use their configs to replace contents of domain.com.conf and domain.com.ssl.conf vhost files replacing all instances of domain.us with domain.com in domain.com.conf and domain.com.ssl.conf vhost files
    3. then switch /home/nginx/domains/domain.us name with /home/nginx/domains/domain.com so rename /home/nginx/domains/domain.us to /home/nginx/domains/domain.com and rename /home/nginx/domains/domain.com to /home/nginx/domains/domain.us
    4. at this stage accessing domain.us and domain.com should go to the same site/forums and work
    5. then in your domain.us.conf and/or domain.us.ssl.conf nginx vhost server{} contexts do a return 302 temp redirect to domain.com and check
      Code (Text):
       server {
         server_name domain.us www.domain.us;
          return 302 $scheme://domain.com$request_uri;
       }
    6. So your domain.com.conf and domain.com.ssl.conf vhost files contents will look exactly like your previous working domain.us site's vhost files prior to move just with domain.com instead of domain.us referenced throughout and your newly updated domain.us.conf and/or domain.us.ssl.conf nginx vhost for old site now contain server{} context based return 302/301 redirects to domain.com
    7. Update your Google Analytics, Google/Bing Webmaster Tools accounts for site domain if applicable etc. Give it a few weeks to see and if all okay, change the return 302 to return 301 for permanent redirect