Change ServerName / VirtualHost configuration:

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

New Domain

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 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          (/etc/apache2/sites-enabled/000-default.conf:4)
*:443                  is a NameVirtualHost
         default server (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
         port 443 namevhost (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
         port 443 namevhost (/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/"
User: name="www-data" id=33
Group: name="www-data" id=33

Can anyone please help me with removing so all points correctly to

Any help would be greatly appreciated


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
December 18, 2021
Accepted Answer


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:

  • 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', '' );
define( 'WP_SITEURL', '' );

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

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

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.