Accessing Your WordPress Site From The Root Folder
Update June 06, 2010 – This is an old post and I actually never do this any more. Please see the comments. Thanks.
I see a lot of people asking how to make their WordPress site accessible from the root directory folder. In most standard installations, WordPress is installed in a sub-folder and the only way to access the site is to add that sub-folder name to the site’s URL.
If you read the wordpress.org support forum you’ll find posts suggesting that you move the WordPress index.php file to the root folder and change a few things in that file. You’ll also see replies from people who have tried it unsuccessfully.
Here’s a little trick that will allow you to access your WordPress site from the root URL without moving or modifying any of the WordPress installation files. This method will “hide” the WordPress installation’s folder name when people access your home page but they will see the folder name in URLs when they start clicking around…
Check your root folder for a file called .htaccess (note that the dot is before the file name). If there is one, download it. If not, create one with a plain text editor such as Windows Notepad. Make sure that when you save it, the file type is set to “All Files” so that your editor doesn’t try to add an extension onto the file name.
Make sure that these lines are included in your .htaccess file. For this example the root URL is shown as domain.ext and the WordPress folder is shown as wpfolder. You will have to change these values to match your own domain name, extension, and WordPress folder name:
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} domain.ext$
RewriteCond %{REQUEST_URI} !wpfolder/
RewriteRule ^(.*)$ wpfolder/$1
Upload this file to the root directory of your web server as a plain text file. You’re done!
Now go to Google Webmaster Tools and let them know the “preferred URL” of your home page so you don’t get penalized for duplicate content.
This article copyright © John Nasta 2009 – All Rights Reserved
You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.


I am working on a website:
http://ldt.tlcphp.com/portfolio/
how do I remove ‘portfolio’ from all the links so that I can open the links http://ldt.tlcphp.com/, http://ldt.tlcphp.com/example.html, http://ldt.tlcphp.com/example2.html etc.
(I added this same question on wordpress help, but thought I should add it here too)
Ok – Here is what I am trying to do. I would deeply appreciate your help because I think I am trying to do what you describe. I want myURL.com/wordpress/home to just look like myURL.com/home.
Call my site myURL.com
wordpress exists in:
myURL.com/wordpress
I have subdirectories for each area under wordpress:
myURL.com/wordpress/home
myURL.com/wordpress/news
myURL.com/wordpress/contact
etc.
Currently, I have a redirect:
myURL.com to myURL.com/wordpress/home/index.php
I added the code you have listed above to the root directory .htaccess file (with all the redirects) and it didn’t seem to affect anything.
Not sure what is going on.
Hi there. This is an old post and I don’t ever use this method any more. I’m not sure why you want /home appended to your home URL and I don’t know what you mean by “I have subdirectories for each area under wordpress”. Also that little trick I posted is only for accessing the home page from the root URL. The real, best way to move your WordPress installation to the root folder (requires knowledge of FTP so read first) is…
HTH
I added your code into the root directory .htaccess file but it did not seem to change anything in the URL but all my images became broken.
http://www.102degrees.com/wordpress/home/
This is what I added:
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} 102degrees.com$
RewriteCond %{REQUEST_URI} !wordpress/
RewriteRule ^(.*)$ wordpress/$1
Hi. Thanks for this it works well. Just wondering why you’re not using the last bit in the .htaccess statement i.e. [R=301,L]
Do you if we should add it to it or nor?
Thanks!
I’ve read that this code will insure that search engines do not penalize your site for duplicate content:
Options +FollowSymLinks
RewriteEngine on
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3, 9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
There are lots of examples of this type of code available by doing a web search for htaccess redirect.
Here’s a link for searching Google.
Unfortunately they often give you the code but fail to explain how or why it works. I have also seen examples that end with [L,R=301]
I’m still frustrated. I followed your instructions and changed the .htaccess file code to this:
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} sidwebb.com$
RewriteCond %{REQUEST_URI} !WPress/
RewriteRule ^(.*)$ WPress/$1
I get a 404 page error. I can access the blog as usual this way:
http://www.sidwebb.com/WPress
Essentially I am having the same problem that I had using the method described by WordPress. Any ideas?
Is your site on a Windows server or a Unix server? This mod rewrite rule may only work on Unix servers. I have no sites on Windows servers and don’t know the particulars of how to make it work on Windows servers.
You may also be able to go into your hosting control panel and use a redirect. That’s how I did it on http://feefifaux.net before I learned how to do it with htaccess.
I use a Mac. I’m not sure what the server is. But thanks for the clue. It never occurred to me to look in the obvious place (my web host) for an answer. Using the host’s tool I was able to redirect successfully. Here is the code it created:
Redirect /index.php http://WPress/index.php
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} sidwebb.com$
RewriteCond %{REQUEST_URI} !WPress/
RewriteRule ^(.*)$ WPress/$1
The first line is the only difference.
Thanks again for the help.
I’m glad that you found the answer. I also found it through my web host.
[...] help today and trying to understand their directions I became very frustrated, but then I found this site by John Nasta which explains everything [...]
Neat! This took over what I had been doing with 301 redir, and made the displayed URL now be my domain, not domain/wpfolder.
No root index.php for hack attacks.
Am I wrong to assume this helps site security as well as displayed URLs?
Just keep in mind that w/ that .htaccess file in place, you can’t access folders that are outside of the folder you are redirecting to. So, if you are redirecting the URL to:
domain/wpfolder
you can’t access another folder called domain/otherfolder because it will look for it as domain/wpfolder/otherfolder. Basically the rule assumes that the folder you have it set to is always the root, and you can’t access something outside of the root. It would have to be under the root.
I’ve had your blog in my bookmarks for a couple of days now and just wanted to say that I really love your articles! ^^
Detailed…
I see a lot of people asking how to make their WordPress site accessible from the root directory folder…
[...] Accessing Your WordPress Site From The Root Folder I see a lot of [...]