msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

09 Aug 14 Changing the domain name of WordPress

SITUATION:
You’ve had a WordPress site since a while and want to change its URL by which it is called. WordPress needs to have a constant URL to be able to work. If you just configure the web server to use another URL, it won’t work. The original URL stored in your WordPress database, which you gave in WordPress installation interface, will still be used by WordPress to create some redirects and your site won’t work at all.

SOLUTION:
1. – (SPAGETTI) Create a new web server vhost (with your new URL) which will proxy all requests sent to it directly to the old one. Well, this is one way to do it which is not elegant at all and can create some nasty problems when using redirects. But still feasible.

2. – (BEST) Change the name of the WordPress URL in its configuration file. The configuration file, called wp-config.php, is located in the root directory of your htdocs. Just add the following 2 lines at the end of the file which will override the settings in the WordPress database:
define('WP_HOME','//example.com');
define('WP_SITEURL','//example.com');

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: