Are you hosting WordPress yourself?
A great new feature is that you’re now able to keep the WordPress core folders and files in a separate sub folder.
The core files are all the WordPress installation files which you never touch or alter. All the other files which you upload, plug-ins, themes and configuration files are kept apart. This helps greatly to reduce the “unclean” mix of files of your installation. And, reduces the risk of deleting files which you should stay away from (the core WordPress installation files).
Another very helpful aspect of this feature is the ability to soft launch / beta test a new WordPress blog in a less prominent way (e.g. yoururl.com/testblog ) and than move it to the main location with the simple procedure below.
To reiterate: You can apply this in two ways, either by starting in a sub directory and than move the blog to the main URL/directory or you did set up your blog under the main URL/directory and want to move the core WordPress files into its own sub directory.
Below you’ll find the complete description from the WordPress codex about giving WordPress its own directory:
- Create the new location for the core WordPress files to be stored (we will use /wordpress in our examples). (On linux, use mkdir wordpress from your www directory. You’ll probably want to use “chown apache:apache” on the wordpress directory you created.)
- Go to the General panel.
- 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
- In the box for Blog 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).
- Copy the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog 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.
- 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'); - Login to the new location. It might now 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.)
Please feel free to ask questions in the comments section below. I’ll help you to get this set up and working. Thanks!
Thank you very much for your tutorial. helped me a lot. I tested it first on a local installation of wordpress, and works perfect. I will be able now to do it on my website as I am intending to merge my portfolio and existing blog in wordpress. the portfolio will be pages.
Please feel free to ask questions in the comments section below. I’ll help you to get this set up and working. Thanks
You say in step 11:
” .. you should manually copy into your .htaccess file (in the same directory as the main index.php file.)”
When you saw “in the same directory as the main index.php file” – is the main index.php file in the Root ( http://example.com/ ) or the index file in the WordPress sub dir ( http://example.com/wordpress) ?
Cheers
Aidan
Aidan,
I’m referring to the root web directory. Let me know if this helps!
-Marco
I’m referring to the root web directory. Let me know if this helps!
done it ……………good tips ……….my query has been solved
I did follow your steps and installed WP into a subdirectory for multilingual website: /pt/ & /en/ but it doesn’t work properly for the second language and twice the folder into the url like this ../pt/pt/…
I don’t know what’s wrong… could you help? thks anyway
Hi “Imobiliária João Pessoa”,
My instructions help you to move most of the WP core files into a sub directory but it’ll be a little harder to make this work with multiple WP installations. Have you thought about using just one WP installation and than try to utilize a multi-lingual plugin?
Cheers,
Marco
Hi Marco,
Hi have been reading you blog and I have to say that I found it very interesting. I have a question regarding a similar scenario.
I have a static website installed in the root folder: http://www.atwebpresence.com
I have recently enabled a wordpress blog that I have decided of installing under the a sub-folder of the root called blog: http://www.atwebpresence.com/blog/
My question is about the the RSS feed url. Normally, this is being generated by wordpress as follow: http://www.atwebpresence.com/feed/
The problem is that a conflict of the .htaccess file between the root and the wordpress folder is preventing preventing this url from being built properly. I have found out that the real RSS feed url should be this one instead:
http://www.atwebpresence.com/blog/feed/
I was wondering if you could give me a hand with this.
Best regards,
Antonio
Hey Antonio,
Alright, let’s see how we can help you. I just took a brief look at your site and it seems to category/tag feeds seem to use the correct URL. Let’s make sure that WP is set up correctly before we dive into fixing things. Could you list your config of WP?
What is you “home/blog URL” (you’ll find this under “Settings/General”) and what does your permalink structure look like (“Settings/Permalinks”)?
Cheers,
Marco
Thanks Marco,
you’re right it works great for the core files into a sub directory, but still looking for ‘multi’multilingual install… I’ve tried WPML plugin, but it’s not the best for all theme, widgets and plugins tanslations…
I let you know if I find out, it might help some visitors of your great site.
Cheers
Great post. Thank you for sharing!
Is it possible to set up WP in the root domain such as http://www.mysite.com and also in the sub-directories or sub-folders as well? For example, If I want a separate database and WP set up for each of the 3 locations such as http://www.mysite.com/location1
http://www.mysite.com/location2
http://www.mysite.com/location3
Possible or will it conflict with the root installation on http://www.mysite.com? Thanks.
Hi Dan,
What is your goal with the 3 WP installations in sub-directories?
You could install WordPress Multisite and run it as a sub-directory installation. This would enable you to run a blog under http://www.mysite.com and any number of additional blogs under http://www.mysite.com/%5Bsub-site1%5D/, http://www.mysite.com/%5Bsub-site2%5D/, etc. And, they would run independently (separate blogs and logins, etc.) of each other.
What do you think?
Hi Marco
I have a strange problem that has happened both times (two sites) when I have moved the site from the subdirectory to the root to go live. All instructions followed exactly. And the site works in the root. Both sites have a few static pages and a blog page with comments which worked fine when in the subfolder. However, when I move the site to the root, blog comment functionality stops working – I can no longer see the reply box and the links on the right: recent posts, recent comments, archives etc look like hyperlinks but do not click. I have been searching for hours for a solution but can’t find one. I am fairly new to WordPress so perhaps I am doing something wrong. Any help much appreciated.
Angie,
Do you have plugin activated which could interfere? Did you test with all plugins disabled (and maybe switching to the twentyeleven theme)?
That would be my first step in trouble shooting your issue. Let me know if this is changing anything, or, if you find out what the problem was. I’m happy to help fi you give me a little more details after switching off all plugins.
Cheers!
Thank you for the tutorial, this will help me configure my installation correctly.
Hi, thanks for dealing with this particular topic. I think I’m having a little different issue with my WordPress. I put it in a /wordpress subfolder to begin with during install, and I can resolve the new URL to get to the main blog page, and I can go directly to each of the blogs using their respective URLs with category slugs, etc.
But I can’t seem to get the blogs seen or indexed by search engines. I have a theory that having a second sitemap.xml (and lots of other files for the blog) beneath the main site url in a subdirectory may be making it hard to crawl and index. Furthermore, I have an “index.php” already in my root directory and it’s my homepage for my website, so I don’t feel like overwriting that with one from WordPress. Does that make any sense? Could it be that my problem is that I have two full-blown websites, one under the other?
Thanks much in advance for any advice.
Hi Rich,
Here are a few thoughts about solving your issue.
Search engines will only look for the sitemap.xml in the “main folder”/htdocs root of your site (or, you’d need to link to it in your robots.txt file). But there is only 1 (!) sitemap.xml to begin with. The good news is that you can link to as many sub-sitemaps from inside the main sitemap as you see fit.
So, you need to make sure to have either no sitemap at all (let the search bot figure it out by itself), or, you need to integrate the WordPress sitemap into the main sitemap. You can accomplish this by simply placing a link to the (sub-)sitemap at the bottom of the main one (sitemap conform).
Another solution is to manually add all the pages of the main site into the WP sitemap and change the location (in WP plugin settings) to the main/root folder of your site. This way you end up with just one sitemap, too.
Let me know if this helps you to get your WordPress site indexed.
Cheers!
-Marco
Hi
Hopefully you can point me in the right direction. I have a site http://www.refinishingtouch.co.uk that structures much of its content under subfolders e.g. http://www.refinishingtouch.co.uk/bathrooms/index.php.
It also has a wordpress blog installed under /blog/ and while I can get to the blog correctly at http://www.refinishingtouch.co.uk/blog, the permalinks to the individual posts are incorrect as they do not have the /blog/ folder e.g. http://www.refinishingtouch.co.uk/?p=22 (which causes the home page to be displayed) instead of http://www.refinishingtouch.co.uk/blog/?p=22.
WordPress URL is http://www.refinishingtouch.co.uk/blog
Site URL is http://www.refinishingtouch.co.uk
I’ve tried with various configurations of .htaccess in web root folder as well as no .htaccess – any idea what I am doing wrong?
Also if I try changing the permalink to anything other than default I get the “This is somewhat embarrassing, isn’t it? It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.” error page. The instant I switch back to the default permalink setting the blog front page is restored with the posts listed.
TIA
Stuart
Hi Stuart,
I hope my reply is still helpful for you. Not sure why I missed your comment.
You should make your WP and Site URL point to …/blog AND you should make sure that your “Permalinks” also include the /blog/ in it (e.g. /blog/%postname%/ ). I’m pretty sure that if everything works fine on the front page (of your blog) that it’s not set up right in the permalinks setting. That would explain your issue above. Let me know if you got it sorted out. Thanks!
Great tutorial – very well written and with great result.
Hi Marco,
I’m trying to run a wordpress site next to my normal site which does not use wordpress. I put all the files in a subfolder, however I cannot put the index.php and htaccess file in te root because they are being used by my original site. What can I do?
Thanks!
Hi Marijin,
Just put your (WP) index.php in the sub-folder and change the WordPress (and Site) URLs to include the subfolder’s name. And, make sure to add the subfolder’s name in the permalink setting, too (see my reply to Stuart for more details). Does that work for you than? Cheers!
-Marco
Thanks for the tute, very helpful!
I have one very pressing question… the link mysite.com/subfolder now leads to a 404 page, which I’d like to redirect to my home-page, is this a smart redirect to place in htaccess? Please advise!
@AUti: Yes, you could add an .htaccess file in there to redirect visitors to the home page. Probably something along the lines of:
Redirect 301 ^/subfolder/?$ http://mysite.com/
I’ve not tested this myself. Please let me know if this works for you. Thanks!!
Excellent, very clear directions, I’d been pulling my hair out for an hour but simply applying #9 sorted me out perfectly.
Fantastic design! The excellent choice of font and large font size makes reading technical instructions like this very clear.
Thanks, Sasha! Glad I was able to help you!
Thank you, great tutorial! Do you know how I can edit the .htaccess file in the root folder to not rewrite when the /blog folder is accessed?
WP blog,
Could you explain in a few more words what you’re trying to do? I’m not sure that I fully understand what you’re trying to do.
Thanks!
Hi,
I’m very fresh to the web world and WP is proving to be very helpful.
I would like to install WP in a sub folder in my public html folder to test another WP theme. I have made the folder but cannot find how to install WP to then install and edit the theme. What am I missing?
http://www.theflyergiants.co.uk
Thanks
aks
Hi Aks,
It sounds like you have WP already installed in your “main” html folder. Is that right? If you want to install a 2nd WP installation in a subfolder and you only want to get to it by appending the subfolder’s name to your domain then you do not need to follow the instructions provided above.
Simply upload the WP core files into the subfolder and go to that URL and follow the “normal” WP setup process. Just make sure to always enter in the URL of your blog WITH the subfolder’s name.
If you install it the way it’s described above then you’d end up with a WP installation that’ll “show up” on your (root) URL (w/o the subfolder’s name). From your question above it sounds like that’s not want you want.
Please let me know if this helps you to get the installation working. I’m happy to help if you run into any other problems.
Cheers!
-Marco
Hi
I am really new to wordpress. Hope you can help me. The church has the current wordpress website stpaulsanglican.bc.ca
We want to create a new one without taking out the old while the new is being built. according to the old administrator All the files for the regular web site are in the directory “public_html”. He said I can put everything for the new site in a subdirectory “public_html/testing”, and that will appear when you go to
http://testing.stpaulsanglican.bc.ca/ .
Do I have to install a new wordpress in the subdirectory ? How do I go about installing the wordpress in that subdirectory?
Suppose I have a website named xyz.com & I install wordpress in a /blog/ directory. How do I create sitemap for my homepage which is xyz.com page while also haveing wordpress in /blog directory. does any wordpress plugin allow us to do this?