Question

Change ServerName / VirtualHost configuration:

Posted December 18, 2021 164 views
ApacheWordPress

Hi, I have a wordpress droplet that I set up initially on a domain. I have now changed the domain and it has been working, however now it doesn’t seem to be working at all. Details below:


Initial Domain
help.remotefilming.tv

New Domain
remotefilming.com


Now when I visit the site I get the message:


Not Found
The requested URL was not found on this server.

Apache/2.4.41 (Ubuntu) Server at help.remotefilming.tv Port 443


So you can see it is looking at the initial domain that is not used anymore.

If I run apache2ctl -S I can see the old domain is still registered, here are the results:


VirtualHost configuration:

*:80                   help.remotefilming.tv (/etc/apache2/sites-enabled/000-default.conf:4)
*:443                  is a NameVirtualHost
         default server help.remotefilming.tv (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
         port 443 namevhost help.remotefilming.tv (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
                 alias www.help.remotefilming.tv
                 alias remotefilming.com
         port 443 namevhost www.remotefilming.com (/etc/apache2/sites-enabled/default-ssl.conf:2)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

Can anyone please help me with removing help.remotefilming.tv so all points correctly to remotefilming.com?

Any help would be greatly appreciated

Thanks

edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hello,

There are a couple of things that you need to do:

  • First make sure that you’ve updated all of the references in your Apache virtual host from the old domain to the new one
  • After that you would also need to issue a new SSL certificate so that your new domain is also secured:

https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04

  • An important thing that you need to do is to also change the WordPress site and home URLs so that they match the new domain name, otherwise you would be seeing that redirect from the new domain to the old one.

You can do that by adding the following two lines in your wp-config.php file:

define( 'WP_HOME', 'http://remotefilming.com' );
define( 'WP_SITEURL', 'http://remotefilming.com' );

Also a side note but an important one, always make sure to take backups of your website before making any major changes, that way if anything goes wrong, you would be able to revert back to a working version of the site.

Regards,
Bobby

by Erika Heidi
Let's Encrypt is a Certificate Authority (CA) that facilitates obtaining and installing free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. Currently, the entire process of obtaining and installing a certificate is fully automated on both Apache and Nginx with the use of Certbot. In this guide, we'll use Certbot to obtain a free SSL certificate for Apache on Ubuntu 20.04, and make sure this certificate is set up to renew automatically.

Hi Bobby,

Many thanks for your reply. The entire site on the wordpress side is correct including the config file. Also the SSL is setup and correct.

I’m very specifically trying to update the Apache Virtual Host file (your first point), I don’t know how to do this.

The link you sent is more for adding the domain to the Apache, I already have my new domain in place and it is all up and running correctly. I’m trying to clean up the Virtual Host file and remove the old one by udating the file, do you know how to do this?

Many thanks

  • Hi there,

    What I would personally do is:

    • First edit the /etc/apache2/sites-enabled/000-default.conf: file and update all of the references of the old domain to the new one
    • If there is a redirect rule in that file, I would remove it
    • After that I would disable the SSL Vhost by removing the file at: /etc/apache2/sites-enabled/000-default-le-ssl.conf
    • Finally you would need to restart apache so that the new changes would take effect

    Once all that is done, you could follow the steps on how to get a new certificate for the new domain name.

    Make sure to always backup your configuration files before making any changes just in case that you need to revert back.

    Let me know how it goes.
    Best,
    Bobby