The Real Way to Move Your WordPress Site to the Root Directory

Introduction

WordPress is a very popular blog and CMS system based on PHP, and can be a great and fast solution to many web site management and development issues for simple websites, blogs, and E-commerce solutions. By default, WordPress is usually installed in a wordpress directory, which many users move to the root web directory. However, this can result in a website with a URL like http://.../wordpress/..., which is generally not very appealing, especially if it is a production website for sales, or a popular blog.

If you look online, many how-to’s will tell you to run through all kinds of complicated URL rewriting schemes and to run many many commands just to move your WordPress installation, and God forbid you have any plugins installed. Luckily, there’s a very easy way to move your WordPress installation, so let’s get to that.

How To Do It

There are only a couple steps involved in moving your WordPress installation.

Change Your WordPress Location

First, go to the Settings tab on the left side of your WordPress admin page. Then, remove wordpress, or whatever the root directory name is from the URLs in the image below. This should leave you with only the URL of your website (and no trailing slash). Save these settings.

You may see an error, and your WordPress site is likely to go down until the next step.

Change WordPress Directory
Change WordPress Directory

Change the Root Directory of Your Apache Installation

Now you will need to edit your Apache configuration for enabled sites, and change the root directory for your web server. Open up a terminal window on your Linux installation, or SSH into the server. If you are using Windows, you can download a tool like PuTTy to do the SSH part. The config is usually located in /etc/apache2/sites-enabled, so you can run cd /etc/apache2/sites-enabled to get there.

Edit Config
Edit Config

Now, run nano 000-default.conf and change the following line DocumentRoot /var/www/html/ to DocumentRoot /var/www/html/wordpress/, or whatever your root installation directory is.

Change Root
Change Root

Run service apache2 restart to restart your web server, and voila, your WordPress site is now located at the root URL of your website.

Restart Apache
Restart Apache

Considerations

This method only works if you do not have any other websites being served from the root directory, and also mean you will not be able to serve files from the root directory (you’ll have to move them into the WordPress directory). If this is not a concern, and you only host a WordPress website, then you should definitely use this method, and it’s much easier than other methods out there.

Conclusion

This is a very simple and effective method to serve your WordPress installation from the root URL of your website, and can save you a lot of time over other methods. It can have drawbacks if you want to serve multiple sites, but if that isn’t your goal, then this is a great method that will quickly solve your problem.