So you’ve installed WordPress in a folder on your Webhost. Your URL now probably looks something like http://example.com/wordpress. This doesn’t look great and also you probably want people to see your WordPress Site at your domain name e.g. http://example.com. How do you do this? Although there are some complicated ways of achieving this redirect with masking using various means the simplest way is by using native WordPress functionality.
It often makes sense to install WordPress in a subfolder on your Host. This keeps the root of your Webhost uncluttered and provides a logical means of understanding where things are on your Host. By default, if you download and unzip WordPress from WordPress.org, then a WordPress folder is included when you uncompress the download.
So, how do we show our WordPress Website/blog as the root even although it is installed in a subfolder/directory? Just follow these instructions (note: these steps are for Apache/Linux Hosting and assume that your WordPress is installed in the wordpress directory):
- Install and create your WordPress Website in a directory named wordpress on your Host.
- Go to http://example.com/wordpress/wp-admin/options-general.php (substitute example.com with your domain name.
- In the ‘WordPress address (URL):’ field change the address to the location of your main WordPress core files and in the ‘Site address (URL):’ field change the address to the root directory URL.
- Save your changes.
- Copy the index.php and .htaccess files from the WordPress directory into the root directory of your site (note you copy these files so you now have copies in the WordPress folder as well as in the root). You won’t have a .htaccess if you aren’t using WordPress permalinks so don’t worry if you don’t have a .htaccess file.
- Open your root directory’s index.php file in a text editor (Notepad++ is the best php editor out there and it’s free)
- Change the line:
- Login to your WordPress dashboard at http://example.com/wordpress/wp-admin/
- Update your Permalinks at http://example.com/wordpress/wp-admin/options-permalink.php
- Smile 🙂
Your WordPress Site will now be visible at your domain name (without the subdirectory) whether using www or not whilst specifying a ‘preferred’ Page (i.e. canonical). You’ll still need to access the dashboard at http://example.com/wordpress/wp-admin.