Results 1 to 5 of 5

Thread: How to change the domain of website

  1. #1
    Join Date
    Apr 2006
    Beans
    2,655

    How to change the domain of website

    Hi all,

    Would it be possible to change the name of a subdomain website?

    Say;
    Running subdomain of the website - aaa.domain1.com

    To be changed to;
    aaa.domain2.com

    If possible please advise HOW

    Thanks

    Regards
    satimis
    Last edited by satimis; 4 Weeks Ago at 01:19 AM.

  2. #2
    Join Date
    Nov 2009
    Location
    Texas
    Beans
    60
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: How to change the domain of website

    If we're talking external domains, it would require you to purchase domain2.com.

  3. #3
    Join Date
    Apr 2006
    Beans
    2,655

    Re: How to change the domain of website

    Quote Originally Posted by Hwęt View Post
    If we're talking external domains, it would require you to purchase domain2.com.
    Hi,

    Both domain1.com and domain2.com are owned by me.

    Regards

  4. #4
    Join Date
    Aug 2017
    Beans
    98

    Re: How to change the domain of website

    Presuming Linux based hosting with mod_rewrite enabled. Other server types have similar mechanisms.

    If you just want to dump the whole schlamozzle over to domain 2, you can do this in your hosting by setting up domain 1 as an alias of domain 2. That has the same potential flaws as mentioned below. You may have to disable domain1 for it to all work, and wait for the DNS servers to propagate.

    Otherwise use mod_rewrite: add a 301 permanent mod rewrite rule for the entire domain 1 to domain 2.

    Both of the above will redirect all requests to the main page of domain 2. if domain 1 has any pages in the SERPS (and it is PAGES that rank, not WEB SITES) and you have any intent of maintaining rankings, it gets a little more complicated.

    The way I would (hope to) set it up is if the pages on site 2 perfectly mirror site 1, your rewrite rule would be (paraphrased) domain1/(.*) domain2/$1 [R-301, L]. That is, any request for domain1/page1.html will be redirected to domain2/page1.html, and so on.

    The 301 is important. It tells search engines this is permanently redirected, don't lose me! L means last rule to process (so, if you have a bunch of rewrite rules, you can bail and not process any further for this request, which is both efficient and avoids unexpected redirects.)

    If that is not the case (and very often so,) you will have to go through domain 1, page by page, locate an appropriate redirect for each page on domain 2, and build a rewrite rule for it. If some of them are dynamic, as in a shopping cart with query strings in the URL's, it can get more complex but . . . . nothing is impossible.

    The way you would test your rules is to set up domain 1 in a local Apache server and hit all the links affected.


    https://httpd.apache.org/docs/2.4/re...remapping.html

  5. #5
    Join Date
    Sep 2014
    Location
    United States
    Beans
    254
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: How to change the domain of website

    If you own the DNS record domain1 and domain2, then simply change the A/AAA value of domain2 to the same IP as domain1.

    After you've done this, set up your virtual tables to point to the new address.

    In http://etc/apache2/sites-available/:

    Code:
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
    ServerName example.com 
    ServerAlias www.example.com
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    Finally activate it.

    sudo a2ensite example.com.conf

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •