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:
require('./wp-blog-header.php');
to the following, using your directory name for the WordPress core files:
require('./wordpress/wp-blog-header.php');
- 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.
I need to go a little further beyond just having separate folders.
Is there a way to configure WordPress to use a remote location for storing all files (e.g. images, HTML, etc)?
The server that hosts my WordPress site is a virtual machine template that won’t persist content. Any new images or other content I create is lost anytime the server reboots and the original version of WordPress is re-deployed. I do have the ability to modify the instance of WordPress which is installed on the virtual machine image but any changes I make will be static (i.e. all dynamic content is still lost every time the machine reboots).
I would like to configure this hosted version of WordPress to point to some other location for storing all content. Does anyone know how to do this?
I have a UNC name for a persistent file store that I could use.
Michael, Your images/files can be stored anywhere as long as you use an absolute path. For example: http://www.your-website.com/images/great-pic.jpg.
Or, it might be time to get a new web host! Even if your current host is “Free”, what is it costing you in time to do rework each time your changes are lost? I like to use BlueHost http://www.bluehost.com/track/whizbangweb (affiliate link). You pay a yearly fee, and get more storage/bandwidth than most people need, plus you can host multiple domains, so if you’re running more than one website, you only pay for one hosting account. They also give you one free domain name for as long as you host with them.
My goal is to configure WordPress to store ALL dynamically created files (e.g. posts, pictures, etc) on a remote location from the server that is hosting WordPress. If I can do that then I would never lose anything when the server rebooted. I already have the site set to point to a remote MySQL database that persists information. Now I just need to figure out how to do the same thing with the dynamic content.
Michael, as with anything, if you can think of it, someone else has probably already done it. Try checking the LinkedIn WordPress group, and maybe post your question there.
This is cool … but it’s just as easy to use rewrite base to specify perms in the blog directory
Options -Indexes -Multiviews +FollowSymLinks
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
Thank you sooooooooooooooo much you are my savior!!!!! trying to follow wordpress instructions and others i almost lost all my hair from pulling it out, lol. Thank you so much.
After struggling through the WP instructions so many times, I wanted to spare others from the same pain. So glad I could help out!
I am SO thankful for this post. Thank you for being the only solution I could find on the web and for being so detailed. Your solution worked like a charm!
Aaaargh… didn’t work. Internal server error when I go to the site. Only thing I can think is that my index.php file had a different line from what is specified here… I had
require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ );
rather than
require(‘./wp-blog-header.php’);
any ideas?
Not sure why it would be different. Is this a multisite install?
thank you
Thanks very much. For some reason it didn’t work first time around (got a blank page instead), but at that time I also got a 500 error from some other plugin which is now resolved and tried your instructions again and they worked flawlessly. Ta
Eight years later and this post is still giving – thank you.
The usual case for me is also to install WP in its own folder, look at the official WP instructions for fixing the URL/permalinks and curse them for writing it so badly.
I was going to write my own version of the steps for future reference but found this first. Bookmarked! 🙂
I still use this for every site I build. Glad to hear that it’s helping you too!