Here’s the situation:
- WordPress has been installed in its own directory (i.e. www.your_domain_name.com/wordpress
- You want someone to go to www.your_domain_name.com and go directly to your WordPress installation
- A simple redirect will get them there, but the path shown will still be www.your_domain_name/wordpress and you want it to simply show www.your_domain_name.com
WordPress gives directions on “Giving WordPress its Own Directory While Leaving Your Blog in the Root Directory“, but I always initially install WP in its own directory to begin with. Every time I tried to modify their directions and follow them, I’d end up with an error (with maybe one exception). I eventually got so nervous about moving the index to root that I stopped doing it and set up a simple redirect which gave me those ugly subdirectory urls. So, here’s my modified directions that have worked for me.
The following are simply a modification from the WP Codex article “Giving WordPress its Own Directory While Leaving Your Blog in the Root Directory.”
Many people want WordPress to power their site’s root (e.g. http://example.com) but they don’t want all of the WordPress files cluttering up their root directory. WordPress allows you to install the WordPress files to a subdirectory, but have your blog exist in the site root.
This process will keep WordPress in its own directory and move the index file to the root directory. It may help to print out these instructions before you start:
- First do a FULL backup of your website, including databases.
- Go to the administration area of WordPress and go to the General panel (under Settings).
- In the box for WordPress address (URL): change the address to the new location of your main WordPress core files. Example: http://example.com/wordpress (This step is not necessary if WordPress was already in it’s own directory before starting this process, but it’s a good idea to check anyway!).
- In the box for Site address (URL): change the address to the root directory’s URL. Example: http://example.com
- Click Save Changes. (Do not worry about the error message and do not try to see your blog at this point! You will probably get a message about file not found.)
- Move your WordPress core files to the new location (WordPress address). Example: http://example.com/wordpress (This step is not necessary if WordPress was already in it’s own directory before starting this process.)
- Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress directory into the root directory of your site (Site address). The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are not using pretty permalinks, then you may not have a .htaccess file. If you are running WordPress on a Windows (IIS) server* and are using pretty permalinks, you’ll have a web.config rather than a .htaccess file in your WordPress directory. As stated above, copy (don’t move) the index.php file to your root directory, but MOVE (DON’T COPY) the web.config file to your root directory.
- Download your root directory’s index.php file to your machine.
- Open your root directory’s index.php file in a text editor
- Change the following and save the file. Change the line that says:
to the following, using your directory name for the WordPress core files:
- Upload your changed index.php file back to the root directory of your site.
- Delete any other index files (index.html, index.htm) that are already in your root directory (after you’ve saved a copy of them, of course)
- Login to the new location. It should still be be http://example.com/wordpress/wp-admin/
- If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can’t write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)
*I have only done this procedure on a Linux server, so I the instructions about a Windows (IIS) server in #7 have not been tested by me.