Q. I’ve installed my website in a subdirectory of our domain, because I didn’t want visitors to see the site until I was finished with our development.
Now I want to have the site show up in the root directory (not in the http://mydomain.com/wordpress directory). How do I do this? I’ve read the information on moving WordPress, and it seems really complicated.
A. The good news is that you DO NOT need to MOVE WordPress in order to have your content display without the subdirectory name. You only need to move 1 file and change one line of code and make one modification to your General Settings, and you’re good to go (see instructions below).
Installing WordPress in a subdirectory is good idea because:
- It keeps your root directory clean and tidy (in case you need to add any other PHP applications to your site).
- It adds another layer of security by obscuring the location of your WordPress application files. Ideally, you want to name the subdirectory something not too obvious (ie don’t call it wp or WordPress). I’m not sure how obscure this really makes WordPress, because you can obviously get the subdirectory name from any images uploaded to the site, since they will still read as sitename.com/subdirectory/wp-content/uploads/image.jpg, so I usually install WP in a subdirectory for development purposes or to simply keep the root directory clean in case I install any subdomains or other applications.
- It allows you to develop a new WordPress site while maintaining your current website in the root directory. Once you’re finished with your WordPress development, you can backup and then delete your current site’s files, and use the following instructions to display WordPress from the root directory of the site.
“Moving” WordPress from Subdirectory to the Site’s Root Directory
1. Install WordPress as you normally would, but instead of installing it in the root directory (ie in the www or public_html directory), install it in a subdirectory in the www or public_html folder. Before continuing with this process, I highly recommend:
a) de-activating caching, broken link checker and any redirection plugins;
b) removing any old site files from the root directory — perhaps copy them to a folder called _backup;
c) making sure you don’t have any other folders in the root directory that have the same name as any pages on your WordPress site, for example “blog” unless of course this is the name of your subdirectory install of WordPress in which case you cannot have a page of the same name because the browser will get confused and look for that page in that folder, then things are really confused;
d) using wp-db-backup to make a backup of your database;
e) getting access to your database via phpMyAdmin on your web host’s control panel in case you type the URLs wrong in the next step. Your database username and password are in the wp-config.php file.
2. Once you’ve completed your design work, adding pages to the site, etc., login to the WordPress Dashboard. From the Settings -> General tab, set your WordPress address URL to the subdirectory you installed WordPress in (without the trailing slash). Note: This will already be displayed in the WordPress address field, so you don’t have to change it. What you do need to change is the Site address URL. Set this to your site’s root address (without the trailing slash).

3. Next, using an FTP application or your web host’s File Manager, DOWNLOAD the index.php file that is in the WordPress application directory (not the one in your theme’s folder or elsewhere) and then UPLOAD the copy you downloaded to the root directory. (By root, I mean the www, htdocs, or httpdocs folder — NOT the root of your hosting account! You simply want to upload the copy of the index.php file and put it in the parent folder of your subdirectory which presumably is the location for the main URL of your website.)
Alternately, you can use your FTP application and MOVE the index.php “to the parent” but then you MUST read and follow step 6 below.
(Note: If you have a site already in the root directory, such as an old static html site, then you should backup and delete those files first.)
4. In a text or HTML editor, open the index.php file that you just copied and/or moved to the root (aka main url) directory and change the location of your wp-blog-header.php to tell WordPress where it can find the WordPress application files in the subdirectory:
Example: if your WordPress installation folder is ‘mywp’, you would change:
<?php require('./wp-blog-header.php'); ?>
to
<?php require('./mywp/wp-blog-header.php'); ?>
Important: Be sure you type this correctly! A missing / or too many slashes or missing period or apostrophe can make this not work. Believe me, I’ve seen people be totally freaked out things didn’t work and it was because they typed this line wrong.
5. Visit the site and click an interior page to make sure it displays correctly. If it doesn’t, you may need to update your permalinks (Settings -> Permalinks and click Save Changes). If you still cannot access your interior pages, then the .htaccess may need to be moved to the same location as the index.php file (i.e. the root directory). This is not necessary on all web hosts. Be sure to update the permalinks again after you move the .htaccess file.
Remember that your login and registration links will still be http://www.yoursite.com/mywp/wp-login.php.
Now, when people visit your site, they will see all the URLs of all the pages and posts as if you had installed WordPress in the root directory, and you will have a neat WordPress directory behind the scenes.
Note: If the site you are redirecting to the root previously was your live site, and you have a lot of posts whose URLs you do not want to change, e.g. from http://www.yoursite.com/mywp/post-title/ to http://www.yoursite.compost-title/ then you should change your Permalink structure to INCLUDE the old subdirectory name (e.g. mywp), so none of your post hyperlinks break. For example:
/mywp/%postname%/
The /mywp/ will only be in the URL of the posts, not the pages.
6. Create a “Silence is Golden” index.php file in the WordPress directory.
If you copied the index.php file instead of moved it, this step is optional. Essentially, you don’t “need” this duplicate index.php file in the subdirectory because it doesn’t really do anything other than prevent people from reading the directory contents. However, if you moved the index.php file leaving the WP directory without an index.php file, then you should create a new blank index.php file and put the following code in the file:
<!--?php // Silence is golden. ?-->
A Note About Using Cforms if WordPress is Installed in a Subdirectory
If you are using Cforms contact form plugin for WordPress, you will need to tell the Cforms javascript that Cforms is in a subdirectory. You’ll want to do this BEFORE you activate the Cforms plugin. Hyperarts.com created a good post about how to do this:
Telling Cforms JS that WordPress is installed in a subdirectory
A Note About Web Hosting
If you have a current site with a non-WordPress friendly host, you may want to set up hosting with a WordPress friendly hosting company and move your current site’s files to the new host and then install WordPress as instructed above.
Problems?
If you have any trouble with this process, please visit my FAQ at: http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/
Please comment on that page.
Success?
If this process was successful, please comment with a thumbs UP below, share on Twitter, follow me on Facebook. Thanks!!!
Where were you when I was trying to figure this out a few weeks ago? LOL! Great tips!
LOL. Sorry, Terence, next time, shoot me an email! You know I’ll write a special post just for you
I’ve been developing a site in a subdirectory and we’re ready to go live. The instructions here and on Bizquarium’s site make sense, but my index.php file does not contain that line! I did a search for the line “wp-blog-header.php” in all of my WP files, and it did not appear anywhere! I’m not sure if this is a quirk of the ComicPress theme or what, but I’m not sure what to do.
Hi Kira,
The index.php file that needs to be moved and edited is the index.php file that is in the main WordPress application directory. This is at the top level of your WordPress installation. It’s not in the themes folder or any other folder. Please give me a call or email me again if you have questions.
Also, remember to MOVE this file, don’t copy it. Another note: be sure to edit the General settings exactly as shown above.
Once you’ve successfully done this once, it’s a piece of cake. One more thing to consider: you may need to go to Settings > Permalinks and click Save to prompt a rewrite of the permalinks to the new location. I’ve only found this to be an issue on GoDaddy hosting. GoDaddy updates it’s mod rewrite once an hour, so you might have to do that and sit back for a bit to see the URLs rewritten to the new root directory correctly. Blue Host, Host Gater, and Host Monster work instantaneously with the updated permalinks.
Good luck!
Angela
Hello, I use Yahoo for my Web host. They have great support but I’m wonder if there is something wrong with Yahoo and WP.
I update something using WP it then will update my pages (somewhat) then slowly update my goldmineexpert.com/gold (installed blog folder) but it will not update my main goldmineexpert.com. I just notice after many hours the changes did come thru.
Do you have any comments about Yahoo or experienced this problem?
thank you bob
Hi Bob,
I’m looking at your site again. Disregard my previous reply. It looks to me like you need to check your General Settings again as indicated in this post and be sure the Blog Address (aka Site Address) is the root directory and that you’ve MOVED (not copied) the Index.php in the WordPress directory (the gold directory) to the www or public_html folder of your site and then made the code change to that index.php as indicated above (< ?php require('./gold/wp-blog-header.php'); ?>), then go to Settings ->Permalinks and click Save Changes.
Angela
You may also need to move the .htacess file to the www folder. If you’ve installed WP using Yahoo’s tools, redirecting the blog to the root directory may be an issue, because I don’t know if you have control of the .htaccess file. Yahoo has nice services, but it also restricts some of this functionality which you can readily do with another web host.
Thanks for your reply. I will be working on this shortly and will keep you posted. I did run into one issue: When I tried to manually change the site url I got this message and it would not let me change the url.
Warning: Modifying this field will cause your permalinks to malfunction. We strongly recommend that you do not change this field.
Please note that this field should match the web address of your blog installation directory. If you chose to make your blog your home page when you installed WordPress, your blog was automatically configured to display at your domain. You should NOT change the value of this field to match your domain.
Any ideas? thx bob
Hi Bob, Now replying to this post:
The warning is a Yahoo warning. What this means is that you can’t do what I’ve suggested in this post. Yahoo will show the HOME page from the root, but all other pages will show from the gold directory, and you can’t have them show from the root directory. Sorry.
well, I moved the index file to the root but still could not change the Site URL or could not adjust the permalinks. If you notice on the main page the home button points to goldminegold and the software button goes to a page it can’t find. Feeling kinda stupid at this point. Any additional ideas?
You available to log on and take a look and maybe help with the design?
thx bob
Hi Bob,
I think you are not stupid, but Yahoo is. I’ve been reading some forum posts, and it seems that Yahoo does not allow you to view or edit the .htaccess file, which is the file responsible for rewriting the permalinks correctly. This sucks. So Yahoo does not enable you to do what I have instructed in this post, which is to install WordPress in a subdirectory. Your best bet is to go to Tool -> Export and export all your posts. Backup your wp-content folder. Delete your WordPress install and reinstall WordPress in the root directory, then go to Tools -> Import and import your posts and copy back over your wp-content folder. You may need to check your image links in your posts because those will still be pointed to the gold directory. Before you go to all of this trouble, you might find call Yahoo and explain to them that the .htaccess file needs to modified to view the pages/posts from the root rather than the subdirectory. I don’t know if they can modify that for you, but it’s your only hope.
Another old post from SEO Egghead had an interesting fix to put some code in that index.php file that you moved which does a redirect of the site. You might try this before going to the trouble to reinstall everything in the root. Be sure to complain loudly to Yahoo as well. Here’s the post:
http://www.seoegghead.com/blog/seo/yahoo-hostings-lack-of-htaccess-support-p8.html
You’ve been a great help. I will try both suggestion and let you know what happens. What provider do you recommend to your clients other than Yahoo. I don’t mind moving. I have another site at Network Solutions are they any better ? I’m actually thinking of moving from them cause there more expensive than the current going rates. Maybe I will move all my urls.
Thanks again bob
Network Solutions connections to their MySQL servers are really slow, so are Go Daddy’s – so working in the WordPress Dashboard can be excruciatingly slow and tedious at times – and the page load times are very slow. I had to move clients off of both of them because of this. On Network Solutions, one site ended up going down several times in a few months because their shared hosting server was hacked at the root level. It was intensely time consuming and frustrating. The client lost all Google ranking as a result of being down for so long. Once we moved them to Blue Host, their ranking came back after a couple weeks, and the site loaded many times faster.
You might want to join the WordPress Group on LinkedIn. There was a great discussion about web hosts for WordPress. Some good hosts are: Host Gator, Dreamhost, Blue Host, and Host Monster. Blue Host and Host Monster are the same company out of Provo, Utah. They have great customer service, but I’ve had several sites down 3 or 4 times over the past several months. They had some power issues because Provo is off the grid and produces it’s own power. Host Gator is probably my current recommendation. With shared hosting, you just never know. I’m using Known Host for VPS, but that’s expensive compared to shared hosting.
[...] For detailed instructions, please see: http://askwpgirl.com/how-do-i-move-wordpress-from-a-subdirectory-to-the-root-directory/ [...]
Great post Angela! Superb resource for WordPress users. Thanks for giving this outstanding support.
Thanks, Doug! You’re welcome. Glad to spread the love.
Hi Angela,
Thanks so much for the great blog! It’s so useful.
This post is exactly what i’ve been looking for, however i’m having some trouble, I followed the post above, ie changed the site name, moved my index.php and changed that line of code (to “./working/wp-blog-header.php” in my case, as my files are in a subdirectory called “working”) and updated my .htaccess from within wordpress, the .htaccess was in the root directory of the entire site already. My site is http://www.corkaccommodation.ie, none of the links are working for me, any advice?!
Thanks again for taking the time to do this blog!
Maria
Just saw this…
http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory It says ‘Copy (NOT MOVE!) the index.php…” are they wrong?! I moved, not copied, as per your instructions.
Thanks Angela!
Hi Maria,
Yes, the codex has this very confused. That is why I wrote the blog post. You do want to MOVE the index.php. And, you should put a blank index.php with the Silence is Golden code in the WordPress directory that you just moved the other index.php file from to prevent people from being able to read that directory. The wp-content folder has a Silence is Golden index.php file in it that you can copy.
Some hosts want the .htaccess in the same directory as where you moved the index.php and some don’t. Only one of the hosts I work with required me to move the .htaccess file. You usually don’t have to edit the .htaccess file, as going to Settings > Permalinks and clicking Save Changes will usually rewrite the .htaccess file for you. If it doesn’t, sometimes just deleting the contents of the .htacccess file then going to the Permalinks and clicking Save Changes will do the trick. You have to be patient because some hosts like GoDaddy update the mod rewrite once per hour, so sometimes you have to click Save Changes and walk away from the computer for a bit.
Glad you got it working.
Sorry for the millions of replys! I ended up making some edits to the .htaccess file & now it seems to be working (fingers crossed!). I moved it back into the subdirectory, got the code that was needed from inside the wordpress admin site, deleted what wordpress had updated the .htaccess file with and replaced it with the new code, then moved it back up to the root directory, phew! So now it seems to be working.
Thanks again for the great blog, sorry for the bombardment of replies!
Maria
HI Angela,
I am trying to follow these instructions but when I try to move the index.php file to the root directory I get an error message saying that this file name may already exist or I may have typed the directory name incorrectly. As I had already moved the index.htm file from the root directory (and now can’t move it back – same error message) I have an existing site that now doesn’t display and my new site (which was set up in the subdirectory of /development) can’t be moved. Any ideas?
Thanks
Neil
Hi Neil,
Open the index.php file that is in that directory and check the content. If it’s “Silence is Golden” or starts with a PHP template tag to “get_header();” then you moved the wrong index.php to the root. Let me know what it says. The index.php file you want to move contains the following text:
< ?php/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
?>
You will want to completely remove your OLD site, because the browser may get confused between trying to load the index.php versus the index.html file.
I find it helpful to use an FTP application like Transmit (for Mac OS) or WS-FTP Pro (for PC) for file transfers because sometimes working in the web host’s file manager can be confusing.
Angela
Thanks for the info… works fine. Just to let you know – Networks Solutions is hosting the site and I needed to do the permalinks save.
Cool. Glad it all worked out! It seems saving the Permalinks is really more of a mandatory step, because the .htaccess mod rewrite needs to get updated.
thanks Angela….thats what I needed last nite and what I couldnt figure out after a couple of beers!
Angela,
Many thanks for this tip, which worked like a snap!
Couple questions, though.
It seems as though my Contact Form 7 autoresponder e-mail message command no longer works following the program switches you recommend.
Also, the web access speed became really slow upon implementing your recommended changes.
Any thoughts as to what is going on with these items?
Hi Danny,
It’s possible that the Contact Form plugin does not know how to reference itself in the sub-directory. You might need to check their documentation or try to uninstall and reinstall the plugin.
In terms of the changes on this post (moving WP to reference from the root directory), that would not cause slowness on the site unless perhaps, and I’m just making a wild guess, that a certain plugin is not working properly after this shift. You might try disabling any suspect plugins, like the Contact Form 7 and see if that resolves the slowness problem. Without knowing more about what your set up is, it’s hard for me to know what else to suggest.
Keep me posted!
Angela
I notice that you have several posts about wordpress-friendly hosting companies. I’m using Network Solutions as a hosting service, but the slowdown seems to be caused by the recommended changes. I would have mentioned the hosting issue in my earlier post, but it did not seem relevant to the problem I encountered.
I deactivated all plug-in’s and it’s still bone slow (4.703 second(s) (0.264 s/Kb) load time based on woorank). My regular site, which is not wordpress-based, is around 0.1 second or less.
Hi Danny,
I had the same experience at Network Solutions with my WordPress sites. The problem has something to do with the location of the database server and how WordPress must connect to that server to render the content. In this case, the best thing you can do is install a plugin called W3 Total Cache. This plugin will cache all the pages on the site as HTML pages. Everyone should run a caching plugin with WordPress especially if they are on shared hosting. You will want to go to the W3 Total Cache preferences and exclude your contact page from caching, otherwise if you have a captcha or anti-spam challenge, it won’t work. Please note that the W3 Total Cache does not show cached pages for logged in users. So, set the plugin, then open a different browser or log out and visit all the pages on the site to force the pages to cache. You should notice about a 700% improvement in performance.
Angela
Angela,
Well great minds think alike, or discover similar solutions. I discovered the W3 total plugin after NS technician told me it wasn’t their fault for my complaining about a 4 second upload. When I installed W3 Total Cache and enabled everything except CDN [I don't know what CDN is, nor do I have any clue what to put into the prompt box], I got a crappy woorank score [I'm using woorank as a tool to evaluate the site optimization parameters.] I got blazingly fast upload times that were reduced from 4-15 seconds to at 0.11 sec, which is what I wanted. But it killed a lot of other parameters [stripped out my title, my description, my images, all headers—presumably this is due to everything being converted to an HTML format?? So I disabled W3 Total Cach this morning.
Then I read your post, got curious again, and tried a couple things. First, I enabled only Page Cache. That single functionality was responsible for the blazing speed (0.11 second load time) and the stripping of much data (presumably due to Page Cache converting everything into html code-speak. So that explains why woorank gave me a crappy score, despite the considerably improved load times.
So next test that I did was to enable everything except Page Cache and CDN. Bingo! Improved load speeds (0.30 second load time) and improved woorank score (up 4 points).
Finally, I tested the contact forms for their functionality. Everything works okay without conflicts!
One last question (or two): how does one reset the permissions, mechanically speaking? I noticed that there was a highlighted box about this, but I ‘ve not the faintest idea how to do this.
Second, what do I do with the CDN functionality, leave it disabled?
Thanks!
Hi Danny,
I’m just now learning all the W3 Total Cache settings myself, so I’m sorry I can’t be of much help. CDN allows you to host the cached files elsewhere, like on Amazon S3 cloud. Here are a couple tutorials on Total Cache that might be helpful:
http://zemalf.com/1443/w3-total-cache/
http://www.wpbeginner.com/plugins/how-to-install-and-setup-w3-total-cache-for-beginners/
http://www.strictlyonlinebiz.com/blog/speed-up-wordpress-with-w3-total-cache/1231/
Thank you for the great article! This was really a timely find for me as I have been researching and procrastinating this very change on my site.
Several years ago I opted to install wordpress into a subfolder to use it as an “add-on” blog for my static html pages. Over time WP has grown up into a nice CMS and I migrated my static html pages into WP pages leaving an index.html at the root level for an entry point.
Now I have over 500 pages and images at http://www.mydomain.com/blog/ and would like to get rid of the /blog/ part. I worry though what will happen to SEO and incoming links and internal links to images etc.
Would you please expand a little on your article to cover the pitfalls and procedures? I know I would really appreciate it!
Thanks for the clearly written, simple instructions!
Okay, one problem: When I try to preview a post before posting, I get a 404 error. Any ideas?
Hi Michael,
Be sure all your pages are working fine first – click on your posts to be sure the permalinks with the new location are working fine. if not, you probably need to update your .htaccess file. This can be done be going to Permalinks and clicking Save Changes. If that doesn’t work you might want to open .htaccess in your FTP application and then delete the WordPress info there, and then go to Settings > Permalinks and Save Changes. This will rewrite the WordPress portion of the .htacess file. Let me know if that does the trick.
I have the same problem Michael did. I successfully went live about a week ago by simply moving the index file to the root directory and changing the site URL under the general settings. However, now I cannot preview drafts or view published pages from the admin window (it tells me I don’t have permission or, in the latter case, generates a error). The difference between my situation and Michael’s is that I’ve never found the .htaccess file in my WP directory — maybe because I haven’t set up permalinks? To solve the preview problem, do I need to somehow create this file?
Very interesting. I had that happen once. Here are some things to check:
1 – Make sure you edited the index.php file per the instructions to tell WordPress the subdirectory name. Also, be sure you moved (not copied) the index.php from the root install of WordPress (not the theme index.php) to the root of your www or public_html directory.
2 – Make sure the WordPress URL in the General Settings contains the full URL to the WordPress installation with the subdirectory name in it and NO forward slash following it (see above example in the instructions) and that the Site URL does not have the subdirectory
3 – If you haven’t ever set the permalinks, ie you’re using the default URL structure (eg ?page=123), then you probably don’t have an .htaccess issue because the .htaccess only comes into play if you are not using the default permalinks. Be sure you are using Default in the permalinks area to eliminate this issue as a variable. Using default permalinks will not result in a preview problem.
Please check 1 & 2 above per the instructions in this post and let me know what you discover. Please feel free to email me directly through my contact form at http://moongoosedesigns.com.
Hi,
I’m having this same exact issue – did this person resolve it? I had permalinks at first, but then I turned them off to eliminate confusion on my part, and as a result I cannot access the domain.com/wp (preview) from the admin panel. When I type this is directly, it says error 403… Totally lost! Also, the Silence is Golden plugin has not been tested with the current version of WP – and there is no data on compatibility. Do you know if it works?
What a great post and a great site – sorry to add to the volume of questions! Thank you!
- Oh and my hosting provider is WestHost, and they use Cpanel in case that helps. Thank you!!!!
The issue with the permalinks with a few users on this thread is that they are with a web host who doesn’t support WordPress very well, such as Yahoo. In these cases, the web host does not allow them to create a .htaccess file, and their permalinks didn’t work unless they included index.php in the permalinks structure or didn’t use permalinks.
When you follow the instructions in my post it’s important to note:
1 – you must edit the index.php file to include the subdirectory (see step 4 above)
2 – you will access the WordPress Dashboard at the same location you used to access it: domain.com/wp/wp-admin
3 – if your web host allows you to create .htaccess files, then you can manually modify or create a .htaccess. Some hosting situations require that it be at the root directory rather than in the subdirectory. See http://codex.wordpress.org/Using_Permalinks for more information on the code that goes in there.
4 – when following these instructions, you will be able to view the pages on your site from the root directory rather than the subdirectory, so, yes domain.com/wp should show a page not found message
5 – your general settings need to be changed exactly as they are exampled in step 2. If you typed these wrong, then you do end up locking yourself out of your account and will need to login to your cpanel, go to phpmyadmin, login to your database (the username and pw can be found in your wp-config.php file), and go to the wp_options table. Browse this table — on the first page is the Site URL – this should be the URL with the subdirectory and NO forward slash at the end. The second page shows the Home URL – this should be the URL without the subdirectory but no forward slash at the end.
6 – So, be sure to check index.php and the settings above. If you are still having issues, email me via my contact form at http://moongoosedesigns.com – most issues are either a little mistake or an issue with .htaccess at your web host.
Regarding Silence is Golden, I am using with 3.2 fine. However, I tend to manually create a the index.php files because I try to avoid using too many plugins.
If you want to reply here, then please let me know:
1 – can you login into the dashboard via domain.com/wp/wp-admin?
2 – can you see the site via domain.com?
3 – what happens when you click on page links from domain.com?
That worked! I had tried going to Permalinks and clicking Save Changes before, and it didn’t work. I didn’t think to clear .htaccess and start from scratch. Thank you very much!
Hey, cool. I’ve found that I do sometimes need to clear the .htaccess to get it to rewrite. I’m not sure if it’s host dependent or what, but I should add that to my instructions above.
Thanks for the great tips – all worked well until I tried to login to my theme via the wordpress dashboard – I am using headway and now I have the Index of/superdynamo( my previous subdirectory name) showing up not opening up my visual editor – any ideas?
Hi Wanda,
After you have the website displaying from the root directory, you will still need to log in via the subdirectory, because the actual WordPress application files are still in the subdirectory. I’m not sure what’s going on with your visual editor — are you referring to the visual editor buttons? Do you have the Visual tab selected when you go to edit a post? You could try enabling the default theme and then re-enabling your current theme to see if that solves the problem.
Angela
I’ve moved the wordpress installation to a sub directory named /press/… Now the url shows the /press after the .com. How do I get rid of the /press in the URL while maintaining the the installation at the sub-directory?
Thanks for the great instructions.
Hi Andy,
So, you actually moved your WordPress install from the root directory to a subdirectory? If you did that successfully, then you can follow the instructions in this post starting with step 1 in order to get the /press to not display. These instructions are for WordPress installs that are in a subdirectory but for which people want the URLs to display from the root.
Angela
I did the reverse. I installed the wordpress in the subdirectory and then moved the index.php as suggested. It seems to work find now. but I can not seem to get the permalink to get rid of the /press destination. Do you know if actually installing the program in root will eliminate the /press subdirectory?
Thanks
Hi Andy,
Actually, you did it just fine. What you need to do now is make sure you set your General Settings correctly per the instructions in step 2 above. Then, you may need to delete the WordPress contents of your .htaccess file and go to Settings > Permalinks and click Save Changes. This will force a rewrite of your permalinks. Let me know if that works. The whole purpose of my writing this post is to help people avoid having to move the whole WP installation to the root directory, because that has it’s own issues and is a pain in the a**.
Angela
That did it for me. It took away the /press in my permalink. You are wonderful! Thanks a lot.
Sorry, I should say…
to reinstall your theme after you take these steps…
(not in this parti order)
- move index.php and .htaccess to root (not WP subdirectory)
- change header redirect in
- change blog and site urls in WP settings
- remove content from .htaccess
- verify correct permissions of .htaccess [766 or 777] once new blank version is uploaded
- resave permalinks to populate .htaccess
- delete and reinstall your theme
also before you do all this it might hurt a little but it makes sense to do this type of move with plugins disabled and WP default theme active.
cheers to beers!
Thanks for the blow by blow of how you got your site to work. I’ll update this post as well. I have only had to move the .htaccess once, but I have found the need to delete its contents in order to get the permalinks to rewrite correctly. I’ve never had to delete and reinstall the theme. I would suggest that instead of having to delete and reinstall the theme, you might simply be able to activate the TwentyTen theme and then reactivate your own theme. If your theme caused problems, that would be highly unusual as the theme as nothing to do with the permalinks, but I have seen themes have problems and activating TwentyTen theme usually fixes these.
Also, some of your users may find this plugin super helpful when moving wordpress installation directories as the image URLs in MySQL have to be updated after you move.
http://wordpress.org/extend/plugins/search-and-replace/
You don’t ever have to use the Search and Replace plugin if you are following the instructions in this post, because all of the URLs will be correct using this method. If, on the other hand, you actually MOVE the ENTIRE WordPress installation from the subdirectory to the root directory, then you definitely will need the Search and Replace plugin because all of your image links will break.
[...] WordPress in a subdirectory and then redirect it to the root directory later (or never) (see Moving WordPress from Subdirectory to Root), but if you’re only going to be using WordPress on your site and have no other applications [...]
Hi Angela – thanks for the great post. I’m currently helping a friend with a wordpress installation; it’s a bit like the blind leading the blind. She a had a previous install in root, and I’ve put a new install in a subdirectory. The new install is a multi-site, or network install. After she has finished building the new site I will want the root directory to point to the new install/site. Is this possible in a network configuration? The network config uses subdirectories, not subdomains.
Hi Adam,
I just looked up your question on the WordPress.org forums, and here is what I found:
“Giving WordPress Its Own Directory will not work in WordPress 3.0 with multisite enabled. It interferes with the member blog lookup.”
http://codex.wordpress.org/Create_A_Network
So, you will not be able to put WordPress in its own directory. You will need to install it in the root directory of the domain you want to use. I don’t know how this might effect your development process. There is an Under Construction plugin you can install to redirect non-logged in visitors to an Under Construction page while you finish your development.
Angela
Thank you so much for posting this! I looked everywhere for instructions on this, but all I could find was accomplishing the opposite. This was exactly what I needed — clear, easy to follow, and super quick! Thanks again!
I’m glad that was helpful, Lisa!
point 4 is wrong:
Example: if your WordPress installation folder is ‘admin’, becomes
What has the folder ‘admin’ got to do with ‘mywp’ ?
You are absolutely right! Thanks for pointing that out. I just fixed step #4.
Hi, Thanks for the concise explanation. Got one question tho, my site was set on /blog folder and it’s been there for years now. I have used a 301 redirect to direct all traffic to the mysite/blog address. Now, over they years i have attained a PR4 and most internal pages also PR3 including some posts. The question is this, If i go through the move and remove the redirect, do you think i will loose all the internal PR, i know Main PR will remain the same as this is on the domain.
Thanks
Hi, That’s a very good question. You would actually have to do a redirect on those /blog addresses to the new / address. I don’t know how this will effect your page rank. Hopefully, the new 301 redirects will take care of any possible 404 errors, and within a few weeks, Google will reindex those pages (be sure to install an XML sitemap). However, I really can’t guarantee what might happen for sure, but doing new 301 redirects and submitting a new XML sitemap will help.
Thanks for the swift reply. You hit it on the head, i was thinking of doing just as mentioned above but just not sure about the PR too. I know a lot of people say it’s not all about PR but if you had worked as hard as I did to get your Homepage and many page to a PR4 I’m sure you won’t just wanna loose it lool.
Will try it out and let you know how it turns out.
Tops WPGirl.
I did as the instructions requested and all my images and pages work, but where the template adds a “home” button, it relocates to the subdirectory url instead of the root. What do I do?
Try clearing your browser cache. The Home page button via the template really should honor the General Settings just as all the pages and images do unless you manually changed it or set the button via a Custom Menu in which case you can re-add the Home link in the Custom Menu (or theme options) to get the correct link. Let me know if clearing your browser cache doesn’t work. What is your site URL?
Great post!! I’ll be doing this on all my sites…
Remember that your permalinks will change! So, you’ll want to do some redirects if you have important blog posts that you don’t want to go to 404 Not Found pages.
Thanks so much Angela!
You saved me from a huge headache!
Chris
Thanks for the excellent post! I used this approach on a client site and it worked perfectly. However, I’m now trying it on a different site and most of the links (strangely, only child pages and posts) give 404 errors.
I first tried leaving the htaccess file in the subdirectory, which didn’t work. Then I moved it to the public folder, updated permalinks and it worked for a second. Then I edited a WP Page and the links stopped working again. I’ve tried moving htaccess back and forth between the subdirectory and public to no avail.
Not sure what is causing this. Has anyone experienced this problem? Thanks.
Hi Tracy,
If you are on GoDaddy, then you have to wait about an hour for the permalinks to work properly, because they only update their modwrite directives once an hour.
You are on the right track with the .htaccess. One thing you should do is delete the contents of the .htaccess, so WP is forced to rewrite the modrewrite rule. Where the .htaccess file is located depends on your host. You can certainly put a blank .htaccess file in both the subdirectory and the root, then go to the Settings > Permalinks and click save, then see which file WP updated. You’ll have to refresh your ftp folder view to be able to see the modified file. Editing a WP Page should NOT cause the permalinks to suddenly stop working again, so that was likely a coincidence.
Who is your web host?
Angela, Wow what a post, and thanks so much. How would i go about keeping my blog URLs as they are in the subdirectory, to maintain all Pagerank and rankings, but have the pages i create as root files / folders?
Robert – that’s an interesting question. I don’t know what your page rank is like now, but if you do 301 redirects (using the Redirection plugin) on those high ranking blog posts and submit to Google Webmaster Tools that your site address has changed from the mysite.com/subdirectory to mysite.com you might be able to recover from the change and not lose your ranking.
Hi Angela,
Sorry if I’m arriving late for the party! I triple read your instructions, yet I’m still having issues. The WP site I’m working on lives in a directory /wordpress but I want it to appear as if it lives in the root directory. Under Settings>General the WP URL reflects the sub directory and the Site URL reflects the root directory, yet it will not access the sub directory for any of the interior pages. I cleared out both .htaccess files, in the root directory and the WP directory, but to no avail. If I set the Site URL for the sub directory, all of the interior pages can be accessed, but obviously it also reflects the sub-directory, which I don’t want. Permalinks are set as: /wordpress/%postname%. Any help is greatly appreciated. Thanks!
Hi Steve,
1 – Be sure you MOVED not copied the Index.php file out of the WordPress directory to the root directory and then made the modification to the require line per the instructions I wrote.
2 – Your Permalinks settings should be just /%postname%/ do NOT put the word “wordpress” in there.
3 – Clear your .htaccess file once more and go to permalinks > Save Changes. This will rewrite the .htaccess file contents. Check the .htaccess to make sure that it indeed did rewrite. You’ll need to refresh your FTP to be sure you’re viewing the latest .htaccess.
4 – If you’re on GoDaddy, the rewrite may take up to one hour to take effect.
5 – On some hosts, the .htaccess needs to be in the root directory rather than the subdirectory.
These directions work like a snap every time, so the problems are likely related to one of the above not being done properly. If you want me to check things for you, please write me via my Contact page, and I’ll take a look at your settings.
Just a note to anyone reading this post: Steve’s issue was two-fold:
1 – He was using a plugin to set his WordPress URLs to have .html at the end, so he could preserve his EXACT same URLs as his old site. However, he had not removed the old site files from the root directory, so the browser was opening those old files when anyone clicked on a nav link in the new WP site. To solve this problem, Steve removed his old site files.
2 – Steve’s peramlinks were set to be /wordpress/%postname%/ (wordpress was the name of his subdirectory). This caused WordPress to sort of go into a weird loop because it was looking for the pages in the wordpress directory but the general settings wanting to find them in the root, resulting in a page not found. To fix this problem, we simply changed the permalink structure to /%postname%/ and manually inserted the correct peramlinks rewrite code (copied from http://codex.wordpress.org/Using_Permalinks) into the .htaccess file because the .htaccess file was not being generated correctly.
So the main issue was #2, when we got that fixed, then it was obvious that #1 was a problem and deleted those old files made everything work.
Hi Angela!
As a newbie to both web design & word press, I really appreciate the people that take the time to update these kinds of sites!! Right now, I’m struggling with the ‘move’ direction in number three. My URL is hosted by a company that uses parralell plesk, and I have no idea where to find any directories or roots- unless the folders you’re talking about are somewhere within the phpMyAdmin page and I just can’t see them. Do you have any suggestions for next steps??
Hi Celine,
You need to get FTP access to your web hosting account. This will not be done in the control panel or the phpMyAdmin page. What this refers to are the WordPress files installed on your hosting account which you can see via an FTP application in the public_html (or www) directory or via the File Manager in your web hosting control panel. The index.php file being referred to is the index.php file of your WordPress installation. There will be many other files in the subdirectory you installed WordPress in, including wp-config.php. You will want to move this file using your FTP program to the root public_html folder (one level above the subdirectory where you installed WordPress).
If you are not familiar with FTP, you may want to hire someone who is to make these changes for you because you’ll also need to modify that file as well. This is not something I would expect a novice html user or someone who doesn’t know what FTP is to do.
I just did this for my first time ever on a test site…before I move a MASSIVE file that I’m working on. I’m quite new to this and Angela’s step-by-step instruction was so clear! It took me about 10 minutes to do it (so I’d still do the switchover at night). When it comes time to do the real thing, I’ll already have all my apps running that I need (I hadn’t logged into my FTP or launched my text editor)…I think I could do it in 5 minutes. Thanks, Angela!
Hi Erica,
I’m so glad this worked for you. The beauty of it is that you only have to move one file instead of moving the entire WordPress installation, which causes all kinds of problems with broken links to images, etc. I really like working with the FTP application called “Transmit.” It’s super simple to use and lets you “move” a file to the “parent” directory easily. The trick that I haven’t put in the main instructions yet, is that you really need to put a blank index.php in the root directory after you move the WP index.php out of it. This prevents people from browsing your WordPress directory.
To do this, simply copy the index.php file from the wp-content folder, plugins folder, or themes folder. If you open this index.php file in a text editor, you’ll see the words “Silence is Golden.” Make a copy of this and put it in the WordPress directory after you’ve moved the WP index.php out of there.
Unable to locate WordPress Content directory (wp-content)
How do I change my ftp directory and is this fix right
The fix was to change my FTP Root directory to one that includes the wordpress installation folder.
I am using cloudflare and tried to up load a plugin and I get this message unable locate directory
Hi Billy,
I have no idea what you are trying to do and why you are using cloudflare. This post has nothing to do with cloudflare and cloudflare has nothing to do with this post. This post is for those people who have installed their WordPress in a subdirectory and now want to have their posts and pages display from the root not the subdirectory. This does not involve dealing with the wp-content directory at all.
If you are having trouble uploading plugins, you may not have installed WordPress correctly. Plugins do get installed in the wp-content directory. If you have a lousy web host who does not support WordPress properly, you will have issues with installing plugins and themes. I would recommend finding a good web host, such as Dreamhost, Host Gator, HostMonster, or BlueHost.
I have followed all of the instructions and everything is working perfectly except for images in my pages. My portfolio is showing images however. I can’t figure out why. When I look at the html, my images are not relative, they are absolute. Any ideas?
Hi Danielle,
The beauty of installing in subdirectory and then moving that one index.php file to the root is that it results in links to images NOT breaking. If on the other hand, you actually MOVE the entire WordPress installation from the subdirectory to the root, then , all of the images links will break. I’ve never had image links break with the method outlined in this past, though. Only when moving the entire WP directory.
The path to the images should be:
http://mysite.com/subfolder/wp-content/uploads/…
If instead, it shows as:
http://mysite.com/wp-content/uploads/…
then something is wrong perhaps with your MEDIA settings, and the URL to the media is wrong there. Go to Settings > Media and check the path to the media. I usually leave this BLANK and allow WordPress to use the default media location which is what you should do unless you have your uploads in some totally different location in relation to your WP install. Some people feel compelled to put a path in the Media Settings even though they don’t need to, and I’ve seen this screw things up.
If that’s the case, go ahead and set the Media settings correctly to the default location or leave it blank. Then, you can install the Search and Replace plugin and do a find and replace for img src=”http://… the path it’s using now and replace it with the correct path to your images.
Let me know how it goes!
I seem to have done everything correctly. i left everything in my wp folder except moving the index.php to the root. The media settings are the blank, default ones, so my images are in wp-content/uploads/2011/7/image.jpg. You can view the site at daniellerussell.me and see on the homepage the 3 images that are missing, and on the about page where there should be a slideshow, but no images show up. I even tried to move the images to the root folder and reupload the images, but still no luck. I don’t understand why those links aren’t working, but all my portfolio images are fine.
Hi Danielle,
Withthe slideshow, it appears the problem is with this theme’s settings in it’s code when you do slideshows. I did actually have that happen once with a theme. It has it hardcoded to look for the images in the wp-content/uploads folder and doesn’t know how to function when WP is installed in a subdirectory and then redirected to the root. It just still looks for the uploads folder in the wp-content folder rather than subfolder/wp-content.
If you view the source code, you’ll see that timthumb script is not referencing your theme directly correctly on the home page where those three missing images are.
So, you have done everything correctly, it’s your theme that is written incorrectly and can’t find the correct wp path. You can hack into the theme’s files and set the path correctly. I did do that once with a theme that was doing something similar. Anytime the timthumb script was being used to display in image, it couldn’t find it because it wasn’t looking for the theme in the subfolder/themes folder. It’s a pretty easy fix, but I don’t know where to tell you to fix it without seeing all the themes files. You can do a search in your theme files for “timthumb” and you might be able to see the place on the home page template and the slideshow template where it references the theme location. Or it might be in one of the theme’s functions files or other theme files.
For those of you following this thread about moving your WordPress install from a subdirectory to the root directory, I do need to mention that you should put a blank index.php file in your WordPress directory after you move the one that was in there. This will prevent people from viewing the contents of this directory. The Silence is Golden plugin is helpful for doing this automatically. Or you can copy the index.php file that you’ll find loose in the plugins or themes folder that says “Silence is Godlen” in it. Very important!!!
Hi Angela:
I really appreciate your work on this tutorial, and it looks like it works for everyone but dumb ‘ol me. I really could use some help. I (thought) I followed your directions closely, but now I have two issues. Here’s what I did:
Originally, I had my files in a directory named /wp . I moved the index.php file to the public_html directory; changed the “require line” to require(‘./wp/wp-blog-header.php’);
and thought I moved the htaccess file from the /wp folder to the root folder. I am seeing the page now at http://www.thereynoldsrealtygroup.com but it is now “unstyled” (obviously not linked to the stylesheet). When I click on the links, it is coming back with an “internal server error”, and the testing site http://www.thereynoldsrealtygroup.com/wp is showing just the file structure.
I also am unable to log into my wp-admin. I know this must be caused by something stupid I did, quite possibly mixing up the htaccess files, but I would reallllly appreciate your help, lest I completely rebuild the darn thing. Below is a copy of my two htaccess file codes. TIA for any help.
Here is the original htaccess file from the root of the site when it was pointing toward the /wp directory
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
Not sure what this one is:
# BEGIN WordPress
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
# END WordPress
Hi Murray,
No worries. It’s easy to miss a little thing when doing this for the first time. So, what you also needed to do which you didn’t mention is to be sure the General Settings know the WordPress location! If you can’t login to WordPress, that’s a sign that perhaps you may have gone a bit to far with the General Settings and will need to login into phpMyAdmin to fix the settings in the options table. Also, you go ahead and delete the #BEGIN to #END in the .htaccess and see if that solves any problem with logging in. Feel free to email me directly via my contact form at http://moongoosedesigns.com. The .htaccess should NOT contain the RewriteBase of /wp/ nor have ./wp in the RewriteRule. Here’s what it should look like:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Angela:
Thank you for such a quick response! I will contact you directly, as it looks like I am getting off topic here! Thanks again! Murray
Hi Angela:
We are all blessed to have you helping us with this. Thank you so much for your wonderful, rapid and extensive expertise. Thanks again!
[...] all of your files. It does, however, require you to edit some of the code in the index.php file. This site will walk you through it. This entry was posted in Uncategorized. Bookmark the permalink. [...]
Thank you so much! This is working perfectly, I just have one question.
I have noticed that since making the switch, when I click on “subscribe to rss” from my site, the link is broken….where do I go to fix this? Is it simply a matter of editing the url within the right file? Any advice would be greatly appreciated…I’m still a newbie, so I apologize if this is a really dumb question!
Thanks
Hi Danielle,
When I click the subscribe to RSS feed icon in the header, it works perfectly. Though I prefer to “burn” my feeds through feedburner.com, so I can see the stats and offer email subscription as well. I wrote a blog post on how to do this: http://askwpgirl.com/how-do-i-set-up-rss-feeds-on-my-wordpress-website/
You’re awesome!!!!
I have been looking for this information for about a week!
Will this work if I have WP Simple Shopping Cart Plugin installed? I know sometimes you can get a PHP Sessions error when the two urls don’t match….just wanted to check before I jumped into this switch.
Hi Danni,
I haven’t ever really had issues with plugins with this method, because the WordPress directory is still the subdirectory, so no images, or anything like that get messed up, which would happen if you actually MOVED the entire WP installation. WP Simple Shopping Cart Plugin is a very simple plugin, so I sort of doubt it would have issues, and if it does, it will probably be a simple fix to be sure to specify the sub-directory in the code.
Since this method doesn’t cause any major changes to anything, what I would do if I were you is to just do it during a low-traffic time, and test. If it works, great. If it doesn’t, you can just reverse the steps.
Let me know how it goes!
Thanks so much! I will let you know how it goes!
Hi, are there any SEO dis-advantges to not moving to root? I’m told goole penalise if the underlying destination is deeper in the website…
The underlying destination is NOT deeper than the root. The only thing that is deeper than the root is the actual WordPress application, which is just a technical thing and not a search engine related thing. All the URLs are from the root when you use this method of installing in the subdirectory but then following the steps I’ve outlined to display all the pages from the root.
Angela,
Thank you for this excellent post. This should be part of the official Codex! Many of us have working web sites, with an index.php already and thus install WordPress in a sub directory for development. I was struggling on how to best do this, and NOT have the subdirectory name show up when users are browsing the new site. Great instructions.
Thanks for the comment, Paul. I’ll see if I can submit it to the Codex. There are instructions in the Codex for moving from a sub-directory to the root, but they are very complicated. I think they actually have you moving the entire WP install to the root, which breaks all the image links. One thing that’s important, I need to add, is to create a blank index.php file in the subdirectory (a Silence is Golden index.php that you can find in the themes folder), to avoid allowing users to see an index of your WP install. You can use the Silence is Golden plugin for this, and it also has some other nice security features.
This has been the MOST helpful article on moving wordpress domains that I have seen and by far the easiest to follow – Thank you!
Hi, I have a question about 301 redirects. If the root directory has an existing HTML site, then those .html pages will have to be redirected via 301 redirects in the .htaccess file, correct? I have gotten this far, and almost everything works fine. The WP site works perfectly, and the old .html pages all redirect to the WP installation.
However, what about the old index.html file? I can’t redirect that with a 301 redirect. What if a visitor has an older link like http://www.mysite.com/index.html, instead of just http://www.mysite.com? If I remove the old index.html, will the visitor get a 404 error? If so, how do I go about redirecting references to index.html, to the new index.php?
Hi Steve,
When an existing site is in the root directory, I install WordPress in a subdirectory. When it’s time to go live with the new site, I follow the instructions in this post and delete ALL of the old website files including the old index.html directory. Now, everything displays from the root, which is nicer than it displaying from the subdirectory.
Finally, I install the Redirection plugin (http://wordpress.org/extend/plugins/redirection/) and do 301 redirect on all of the old pages, including the old index.html to go to the main domain name url. The Redirection plugin is very helpful for all of this, as you can type the full URL to the old site URLs and type the new URL on the new WordPress install.
Good luck!!!
Hi! I read your blog instructions and several others and sat down tonight to do the work of redirecting my subdirectory site files so they’d show up as root files but it didn’t work out well. In fact, I’ve lost my access to my WP interface. I am feeling a bit overwhelmed and lost at the moment. Can you give me some help for what to do now?
Chris
Hi Chris, You will still access the wp-admin via the subdirectory. I’m heading out right now, but I can help you in about 1.5 hours. Read through all the instructions carefully again, just to make sure you didn’t miss a step, particularly with the edit of the index.php file where you have to specify the subdirectory. See if you can log in to WP via your site URL/subdirectoryname/wp-admin.
Angela! Thank you thank you for your time. My site is working fine now. I so appreciate your helping me to learn more about this option. – Chris
Hi Chris. You’re welcome. I’m glad we could unravel your hosting issue and get things working again. Good luck!
Hi Angela, you’re up too! I’m working on another site, it’s a fresh install of WP into the root but needs to be put into subdirectory while it’s being built. I am trying to move it but I forgot to log on to the dashboard and add the subdirectory folder path before I moved the WP install into the subdirectory. Aargh! Now I can’t log on to the site admin/dashboard. What is the best way to manually edit/fix so I can log on?
(BTW, Speed Racer was my first boyfriend. And what about Marine Boy!? You go girl!)
Wait! Forget that last request for help! I did it! Wow. It’s so nice to try something new (myPHPadmin stuff) and have it work! I think Racer X was helping me out. – Thanks Angela, Chris
Hello! Thanks for this great resource. Please can you tell us – what is best for SEO – wordpress in root or sub directory? I read somewhere that for SEO, it is better to install in root.
Hi Karan, technically, that is correct. However, having your WordPress APPLICATION installed in a subdirectory is NOT the same as having your website pages showing from the subdirectory. This is an important distinction. ONLY the application is in the subdirectory. By following the steps in this post, the actual URLs for all of your posts and pages are displaying from the root.
This works beautifully. But, here is the problem: existing links out there in cyberspace to your original articles don’t work. For example, if you originally published a blog post or article (let’s say its filename is XXXX.html) and published it out and its permalink is:
http://www.your-domain.com/blog/XXXX.html
And now your blog is redirected to root, all NEW articles will get the correct permalink, like:
http://www.your-domain.com/YYYY.html.
But, what if someone sees the original backlink http://www.your-domain.com/blog/XXXX.html and clicks it or just types it into the address bar? Bummer!
So, here’s what worked for me: in the “blog” directory (or whatever you called it), comment out everything in the index.php file and then add this code:
[I deleted the code because I don't want anyone using it. It is perhaps not as secure as it should be--AskWPGirl]
So, this converts “http://your-domain.com/blog/XXXX.html” to “http://your-domain.com/XXXX.html” and all existing backlinks work fine.
You bring up a very good point. After you have followed the instructions in my post, you can use the Redirection plugin to redirect old URLs to the new URLs using 301 redirects or simply use .htaccess to redirect the URLs from the old URL to the new one: http://perishablepress.com/press/2008/10/06/redirect-subdirectory-to-root-via-htaccess/.
Hi thr, got quick question. What if i wanted to point wp-admin directly to root without entring subfolder name ex hello.com/wordpress/wp-admin –> hello.com/wp-admin? is thr anywhr i can fix this via domain management?
The only way to have the wp-admin not display from the subdirectory but still be in the subdirectory is to change your domain management to point your domain name to the subdirectory. In this case, you would NOT follow the instructions in this post and would instead ask your host to use the subdirectory as essentially the www or public_html folder of your site. Then, you would change your WordPress General Settings to the URL of the site (eg http://hello.com) without the subdirectory AND you would need to install the Search and Replace plugin to replace ALL of your internal image links (eg do a search on “hello.com/wordpress/wp-content” and replace with “hello.com/wp-content”). I’ve certainly known people to do this.
when i saw the domain name “girl” i wondered, man, whats she gonna knw! but your post was impressive!!!
its original??? or copied??????? :p
Hi Nabeel,
It probably speaks more to my having grown up with the super heroes of the 70s-90s: Mighty Mouse, The Boy Wonder, Bowler Girl (my personal favorite), Go Speed Racer, Tank Girl, etc. Anyway, yes the content is original. I found another post on bizaquarium that I used to send people to, but their site got hacked, and they were missing some important bits of information, so I was compelled to write a fresh one. Thanks for writing. I like your blog. I’ll follow you.
Angela (aka WP Girl)
Thanks for this great tutorial. It’s the best I’ve seen on the subject.
Just so that I understand correctly, if I want to develop a new wordpress site to replace an existing .html site I could develop the site in a subdirectory and then move it over to the root when it’s ready. In this case, I just want to confirm what my settings should be while the new site is in development.Let’s say I install the new development site at http://mysite.com/new and the existing .html site is located at http://mysite.com
During development of the new wordpress site my settings should be:Under Settings -> General tabWordpress Address (URL): http://mysite.com/newSite Address (URL): http://mysite.com/newAnd then when the new site is finished, I would proceed with your directions. Am I correct?
Hi Joseph,
Yes, you will install WordPress in a subdirectory of your current html site. If you use your web host’s auto installer, then the General Settings in WordPress will automatically show the URL to the subdirectory. If you do a manual install, then this will also be taken care of because the installer for WP will automatically use the subdirectory. In the General Settings it will look like:
WordPress URL: http://mysite.com/newSite
Site URL: http://mysite.com/newSite
When you are done with development, you will follow my instructions. You will want to place all of your old HTML files in a folder called “OLD” perhaps or download them and delete them, so Google doesn’t index those anymore. You’ll want to install the Redirection plugin to create 301 redirects from your old HTML pages to the new URLs for those pages. You do not need to keep the old HTML pages for the redirection to work.
Good luck!
Angela
Hi, WP Girl!
I really have enjoyed your tutorial! It was very handy, because all other instructions directed the user to move all files where their blog was held to the root causing a huge clutter, so thank you! I had one issue that I have been trying to fix, I cannot find my .htaccess file. I am using FileZilla for Mac OS, so first, I checked the “force showing hidden files” option to enable me to be able to view all hidden files and no luck. Next, I tried creating a .htaccess file in TextEdit, pasting the .htaccess into the file, and saving it as 1.htaccess and renaming it simply .htaccess within FileZilla once I moved it to my root directory, but caused my whole site to go down. Also, I tried switching FTP clients to see if that was the issue. The only way that I am able to change my permalinks is if I include /index.php before the rest of my link, which has been alright, but it is causing issues for me now that I am installing other plugins, such as WP E-commerce, since the products and pages that it creates takes out the “/index.php” part of my permalink generating an error message whenever I click any of those links. Do you have any tips or suggestions on how I can change my permalinks or create an .htaccess file, so I do not have to include /index.php in my permalink? Thank you in advance for your help
It sounds like you are likely on Yahoo web hosting. Am I right? Yahoo is not a great WordPress web host. Yahoo does not allow you to create an .htaccess file, nor will it allow you to run BackupBuddy plugin or many other plugins. The server access is highly restricted. Yahoo will force you to do just what you did with the /index.php in your permalinks. My recommendation is to sign up with a host that specifically supports WordPress, such as Blue Host, Host Monster or Host Gator. If you are not on Yahoo, you are on another host that is equally as restrictive.
I am on Shoppepro, because originally, I liked their e-store design, but later, I decided to just go with a blog. Now, I see the downside of staying with them. Thank you so much for your help, I will switch and hopefully that solves my problem
I understand. You’ll need to backup your database and all your files and set up a new blank database at the new host and import your old database into it. There are instructions on WordPress.org on how to migrate a website. I usually use BackupBuddy to migrate sites, because it makes it a piece of cake, but I wasn’t able to get BackupBuddy to run on Yahoo hosting, and I’m afraid you’ll have similar issues on your host. You can use the wp-db-backup plugin to backup your database easily.
Hello again! I solved the issue by renaming the index.html file to index.html.save so that apache looks for the index.php file first. I went ahead and installed the silence is golden plugin and it seems to be fine. FYI for anyone who has a similar issue! Thx!
Yes, you can’t have two index files in the same directory. I wrote to someone else about the same thing. They left their entire old site in the root directory and had matched all their URLs, so of course, the old html files were being pulled instead of the WordPress files. You do need to MOVE or DELETE or rename your old files. Keep in mind that Google WILL index these files, and you will be deprecated for duplicate content on your site, so you should delete your old site files (perhaps download them first so you have a backup) or move them into a folder called OLD and use a robots.txt file to prevent Google from searching that folder.
Thank you for this!!!
Hello again! I followed your tutorial and Everything is working good. Thanks a lot.
Only one thing – I dont get my wordpress admin BAR on top of the page when I am logged in. I have enabled it in my profile to show everywhere. It is good when to edit a page quickly.
I’m glad it worked. In terms of the admin bar, if you have both checkboxes checked to show it on the site and in the dashboard in your user profile, and it still does not show, then make sure your theme has the wp_footer(); php template tag in your footer.php. You’ll see this template tag in the TwentyEleven theme if you need to copy it to your theme’s footer.
I tried this, it did not work for me but i am running some extensive plugins including wp e-commerce and flexishops. I found that writing an index.html redirect in my public html directory worked just as well.
Hi Daniel, that makes sense. Some plugins that aren’t written correctly will have trouble when the URLs are displayed from the root, because then they will look for their content in the root rather than in the plugins directory in the subdirectory. Doing an .htaccess redirect to get all root requests to go to the subdirectory works as well. There was a good post on Perishable Press about how to use .htaccess to rewrite URLs: http://perishablepress.com/press/2008/10/06/redirect-subdirectory-to-root-via-htaccess/
Hi!
Looks like you know this stuff =) i have not been able to find any answer when i google this question..
i am have installed wp in a subdirectory and made all the changes needed so it looks like this
WordPress address: mysite.se/wp
Site address: mysite.se
And everything works, almost… when i press the “home” button i get directed to mysite.se/wp when i want to end up at mysite.se
i have tried different ways but i either ends up with error coeds or blank pages or missing pages…
Do you have any idea what i can try?
Hi,
Go to your custom menu (Appearance > Menus) and make sure your home page URL is set correctly. You probably had Home going to the subdirectory when you were setting things up initially, now you just need it to go to the root. If it’s not set in the custom menu, then your theme may be wanting to send it to the wrong URL, so you can edit that in the header.php file in the menu div. Anyway, it’s a simple fix. Let me know how it goes.
Hi and thanks!
It solved my problem, but it was as an alternative solution.
Because i had Enabled Home button through the Theme Settings…. so i still wonder. But thanks so much now i have a better working site!
Yes when it’s set through the theme settings and doesn’t work correctly (ie you click “show home link” in your theme options), the theme developer did not code the home link URL correctly. You can fix this in the header.php file of your theme. Likely they used the wrong bloginfo parameter for showing the home page link.
Hi Angela,
Thanks so much for your straight-forward resource! Unfortunately, I’m at a point where I’ve tried so many different resources to help me move wordpress from a subdirectory to the root directory that I fear I have messed things up pretty well. Now, nothing seems to work, and I am constantly restoring the subdirectory just to get back to a point where all the material is formatted and intact. Here is the link as it stands in the subdirectory. At some point, I had changed my wp-config.php file to try the overwrite suggested on the WP codex, but now the WordPress Address in my Settings is greyed out and uneditable. I tried downloading a fresh wp-config.php file and repopulate the information, but it turns the blog into a long list of links, followed by unformatted text and images. When I move the index.php file to the root directory and edit it, it also reverts to an index listing of links. I have restored the index.html file so their old site displays while I try to dig my way out of this hole. I also changed the subdirectory “wordpress” to something else as per your suggestion, but it removed all formatting and images, and I wasn’t sure how to adjust the permalinks to reflect the change properly. I look forward to any suggestions you may have for me, as I am about to pull out my last clump of hair. Thank you!
Hi again, and sorry – I went ahead and renamed the index.html file so you can see what I am describing.
Thank you again!
Hi Paul,
You need to have the index.php file that had been in your subdirectory moved to the root directory. In your index.php file in the subdirectory, you now have perhaps the silence is golden index.php which is not the file you want in the root but is good in the subdirectory. If you need to, you can redownload wordpress from wordpress.org and grab the index.php file from there. It’s in with the other wp files in the main wordpress folder. Upload this index.php file to the root directory of your URL, where you used to have the index.html. Make the edit to this file per my instructions in this post.
Next, you should not have done anything with your wp-config.php file.
Finally, login to WordPress if you still can and check:
In the General Settings it will look like:
WordPress URL: http://mysite.com/newSite
Site URL: http://mysite.com
So, the site url should not have the subdirectory.
Lastly, put all your OLD html files in a subdirectory to get those out of the way.
Contact me directly via my contact form if you need more help. I think you’re close.
Thank you very much for this article. Going live with my new WordPress based web site was made easy by simply following the steps above (http://www.visionandvoice.ca). And thanks for my host at canfone.com for finding your article and passing it along to me.
- Gerry Fraiberg
If you have a good site, this method is useless. All your old posts will be dead links in Google. The author doesn’t mention this in the text above, and I had to spend my time undoing everything again.
So, if you have a large amounts of readers from googling, you probably do not want to lose them by doing this. If you have a small site, yeah, go ahead.
Hi,
You make a good point. Having all your posts show from the root, of course, does result in all your posts displaying form the root, hence the URLs do not display from the subdirectory any longer, which is the whole purpose of this process.
If you do have an old site, then you don’t have to abandon this method to address that issue. You can simply do put a command in your .htaccess file to redirect all the old URLs en masse to the new root domain. I have put put this in the comments as well, but I’ll add it to the main post, so people do think ahead about how they will handle their old URLs. Also, the Redirection plugin can be used to redirect the old URLs to the new ones, but if you have a lot of them, then the .htaccess file will work better. You just don’t want to redirect your wp-admin login to the root, because you still do need to access that from the subdirectory.
This is great! And thanks for the info. I have a question if you’re still open to answering.
I am stating my site in a directory and about to go live. I realize now that I want to change the name of the directory that it’s sitting in; and still follow your directions to access from the root. But I’m worried that I’ll break all the intrsite links and images if I simply change the name of the directory via ssh – or ftp; is there a way to do this an not break anything that you know of?
thanks!!
Yes, you will break everything if you change the name of the directory it is in. Luckily, there is a great Search & Replace plugin you can use: http://wordpress.org/extend/plugins/search-and-replace/
So, what you’ll want to do is to change the directory name in the General Settings in WordPress – BOTH settings. Then, change the actual directory name via FTP. Next login to WordPress as the new URL – eg domain.com/newdirectory/wp-admin
Then, use the Search and Replace plugin to change:
domain.com/olddirectory/
to
domain.com/newdirectory
Then, follow the steps in my post to have the URLs of the site display from the public_html (main domain url) and the images of your site and your wp-admin will still display from the subdirectory since that’s where WP still lives.
Let me know if that makes sense!
Hate to be mooch-like but I have a slightly different situation, not sure if the same would apply.
I was rebuilding domainB on domainA.com/blog. it wasn’t a subdomain or subdirectory of the same domain. it’s a long story as to why but i went to do a switch of the URLs from the general settings, and everything got messed up. now things are switching randomly and domainB doesn’t look normal, I can’t log in to either wordpress backend now.
I almost just want to start over. Leave domainB and domainA.com/blog alone and do it some other way. Would I follow this same set of rules since it’s not a subdomain or subdirectory?
Hi Vanessa,
I’m about to write an FAQ for this process, because there are a couple places where people can make a mistake, and if they do, they need to know how to fix it.
To get back into your wordpress on domainA, you need to login to your web hosting Control Panel and go into your phpMyAdmin application and look for the following two URLs in the wp_options table (Browse the table):
option_id 1 – siteurl — you should probably just set this back to domainA.com/blog
on page 2 of this table you’ll find
option_id 37 – home – set this back to domainA.com/blog
Now, hopefully, you’re back go square one (if you moved the index.php file you can move that back into the subdirectory and get rid of the edit you may have made to it). Now, it sounds like you need to MIGRATE your WordPress installation. This is different than what I am describing above. You will actually need to MOVE the entire WordPress installation from domainA to domainB’s hosting account. To do this, the easiest way is to purchase BackupBuddy plugin and backup domainA.com/blog to a zip file. The BackupBuddy zip file will contain a backup of the database and all the FTP files.
At domainB, you need to create a new database with a user and password. This database needs to be blank – ie don’t install WordPress on the new host. Write down all the details for the database. Then, you need to ftp the BackupBuddy zip file along with the importbuddy.php file that you can download via the BackupBuddy interface on domainA.com/blog. BackupBuddy has a great video tutorial on this process. It’s quite simple and is the best way to migrate a site from one domain to another, either on the same server or different server.
Here’s my affiliate link to BackupBuddy:
http://askwpgirl.com/go/backupbuddy.php
When you use BackupBuddy, you can just install the new site in the public_html directory of domainB, and it will correct all the WP settings and URLs for you, so you don’t have to worry about the process I’m describing in this post at all.
Woman, you rule. Total girl crush on the WPgirl. I was able to reset the info in phpMyAdmin so now I don’t have to worry about getting fired at work tomorrow! I’ll tackle the second part after some much needed, bleary-eyed sleep.
Seriously can’t thank you enough!!
Yay! Good luck.
Thanks for the information-I followed your instructions and was able to get my WordPress blog to the root level of my website. The instructions were very helpful to me- Connie
Awesome!
Thank you, Thank you. I found myself in the same hiccup as Vanessa below as I wrote the wordpress directory as the subdomain ie new.cypressridgecottages.com.au rather than cypressridgecottages.com.au/new. It is now up & loaded and only took a couple of minutes after fixing my error…. You’re my hero WP Girl!
Awesome, Shannon. I need to get cape! Actually, I need to write an “FAQ” on this process to address all these little things. Coming soon!
Wow. I was expecting this to be a serious pain in the A** – this post really saved me. Now on to some other thing that I’m not expecting to be a pain…
Very good. Be sure to check any internal links to pages you may have made, so they link to the new url for the pages.
hi
I have a number of hand coded links in pages that refer to the test directory.
eg
Like to buy a print of
this image?
What is the best way to update these, through the DB?
You can use the Search and Replace plugin to replace these, but you have to be careful to search on a href=”…. and not just on the url because then you’ll inadvertently ruin all your image links. To be safe, do the search and replace on the hrefs then do a search and replace again to replace domain.com.au/wp-content with domain.com.au/tests/wp-content — which is correct for your image links.
hey girl.. i have alot of questions since it seems..you are so good in WP.. i hope its ok to ask it here…
umm i have a webhosting server on Ninja Lion and im using 2 domains on that server..its ok right? thats the first question
lool
2nd, im going to link my website on a facebook page..but the problem is ..that the posts i made on the site have a featured imaged as usual..these images do not appeare on fb when i post them.. how can that be fixed? any plugins to suggest?
3rd, how can i change mywebsite.com/wp-admin to mywebsite.com/somethingelse/wp-admin so to be more secured?
4th.. .htaccess should be configured manually ? or by it self..although i know nothing about it..
those are few questions.. yet i have more.. but i dont want to bother you alot hopefully im gonna solve the rest..if not..then i have to ask you again lool
. sorry for bothering.. thanks alot
MadBoy
Okay, MadBoy, I’ll try to answer your questions here simply:
1 – Hosting. Most web hosts do allow you to host unlimited domains on the same hosting account. You have to find out if they “throttle” your bandwidth at all based on hits or downloaded content. Otherwise, it’s fine.
2 – When you manually post a link to your website on Facebook, it looks at any of the images on the page to use as the post thumbnail. However, if the only images on the site are background images in the CSS, then it won’t find an image. It actually has to be an image inserted on the post/page or sidebar — not in the CSS.
3 – I don’t think I would bother. There are many other things you need to make your site more secure, such as have strong passwords, use a backup plugin like BackupBuddy (http://askwpgirl.com/go/backupbuddy.php), don’t use vulnerable themes and plugins. There are too many ways a hacker can figure out what directory your files are in, so other security measures are more important. You’re not going to prevent your site from being hacked if you are using a vulnerable script or plugin simply because WP is in the subdirectory.
4 – A couple purposes for the .htaccess: 1) to make the pretty permalinks work. Usually clicking Save Changes button on the Permalinks settings page will auto generate the .htaccess file. If not, you can create it using an ftp application that is set to view invisible files and give it 644 permissions. Then WordPress can write to it. 2) to make your site more secure, manage page cache, and do redirects. For security, you can try the BulletProof Security Plugin which locks down the WP site via .htaccess.
I hope that helps!
what is the difference between wordpress address url and site address url?
The WordPress Address URL is the URL where the WordPress application is located. The Site Address URL is the address from which you want the pages and posts of the site to be displayed from. The purpose of this post is to show you that you can have the WordPress URL be in the subdirectory, and the Site URL be in the directory above that (ie the root website address), and still have WordPress work. The trick is to move the index.php file that’s in the subfolder where WordPress is located to the parent folder and then edit it to show where WordPress is located. See the instructions in this post for more details.
Hi, I tried implementing this but got this message:
PHP Warning: main(/index.php): failed to open stream: No such file or directory in D:Domainszzz.comROOTInetpubwwwrootblogwp-404-handler.php on line 7 PHP Warning: main(): Failed opening ‘/index.php’ for inclusion (include_path=’C:WINDOWSsystem32inetsrvphppear’) in D:Domainszzz.comROOTInetpubwwwrootblogwp-404-handler.php on line 7
wp-404-handler.php is used as I have Windows server and IIS. wp-404-handler.php is in the sub-folder blog:-
How to change the index.php in this to the new file in the root?
Hi Paul,
Hmmm…. I have no idea where to start here. I’m working on writing an FAQ, because the only times I’ve seen this process not work is when someone doesn’t follow the steps exactly as written. So, first answer the following questions for me:
1 – Where did you put the index.php file and what do you have in the “require” line of the index.php file?
2 – Are you able to login to the WordPress Dashboard?
What is your domain name? You can certainly email me directly via my contact form.
Thx.
Thanks, I’ve emailed separately but had missed out the important step 2. Now the PHP error message goes away but the permalink, without the subfolder in the URL, cannot be found. It goes to our custom site-wide ASP error file, and not the error file created for the blog folder only, wp-404-handler.php, in cases like this where Windows hosting does not allow .htaccess rewrite.
Hi Paul — WINDOWS HOSTING – run as fast as you can! It’s truly horrible, but you should talk to your web host, because they can enable this functionality on the server. It’s not impossible, but they will need to do it. Give them a call and see what they have to say. In the meantime use the default permalinks. I think if you move the .htaccess to the public_html that might help, and you may need to include the /index.php in the permalink structure. Here are more details about the permalink structure you can speak with your host about:
http://codex.wordpress.org/Using_Permalinks
I just wrote an FAQ that might be helpful. You could be having a PHP issues with your .htaccess:
http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/
WOW! I normally don’t take a woman’s advice on most things, but I have to say; this reads well so far and seems to make sense. I’ll be trying this out as soon as I’m done with my project.
I’m not sure if I should be flattered or offended. Why in the world would you not read technical documentation by a woman? The ability to write technical documentation has nothing to do with someone’s genitals. Men are just as capable of writing total crap as women are. Anyway, I’m glad it will be helpful to you.
Hey Jade,
I wrote you an email with some suggestions of things to check. I’m going to write an FAQ for this post, because I have discovered that people do make errors in the process even when they believe they have followed the instructions “exactly.” They are usual simple errors, and we can get it resolved quickly.
I just wrote an FAQ that might be helpful:
http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/
Hey… I went through this method Step by Step and It worked!! But however, my comment form is missing from my posts ever since. I do have the “Leave the Comment” still on my page. please help.
Hi Jeanteena,
Wow, that is strange. It sounds like perhaps there is something with the theme not knowing where to find the comments template. That usually shouldn’t be effected by the subdirectory change. Do you want to zip up your theme file and email it to me? If you email me via my Contact form, I can reply to you. Some themes are not coded properly, and they have URLs to their internal template files that are relative to the wrong thing.
Hi,
My WP installation is in a sub-directory and I want to move to the root. But my server is Windows 2003. Can I follow the same steps? Please advise.
Thank you.
Hi Aneesh,
This process will work just fine with the possible exception of the “pretty” permalinks working as expected. Do you have permalinks enabled on the current site or the default permalinks (Settings > Permalinks)? The nice thing is that you can certainly try the process, which if you follow exactly only takes a few minutes. If it doesn’t work, then you can reverse the steps by first changing the General Settings back to what they were and then moving the index.php file back to the subdirectory and editing it again.
Please read this post from the WordPress codex on enabling permalinks on Windows: http://codex.wordpress.org/Using_Permalinks#Permalinks_without_mod_rewrite
YAY – this does indeed work like a charm – thank you !
jeni
Thanks a mil!
Work perfect – best and easiest instructions out there.
=)
You’re welcome. Yay!!!
you may also need to do a Zeus rewrite for when WordPress is installed in subdirectory so permalinks work.
You will need to check with your hosting company
Thank you so, so much for this. You just saved me tons of time and stress. You are great.
Hey Nate – Thanks for the comment! I hope it all works out for you.
My instructions assume that people are running on an Apache server rather than some not-so-friendly web hosting package such as Windows or Zeus. Apache/Linux is the best environment for WordPress and WordPress plugins to run. If the host is not running Apache/Linux, then permalinks do cause an issue, and you have to check with your web host about how to enable the rewriting of the IDs to the pretty permalink structure, whether via a web.config file on Windows or the Zeus rewrite you mentioned for Zeus servers. I’ll be sure to edit the post to differentiate these different hosting environments.
This post is primarily about “moving” WordPress, but in the process, people will activate the pretty permalinks and have them not work and assume it’s because of the “move” when it was because they didn’t realize that their host didn’t support permalinks for Apache server.
Hey, I found a completely free plugin that automates this entire process. It moves the files and the database and everything automatically. Here it is: http://www.movewordpress.com/
This process I describe is NOT for “moving” aka “migrating” WordPress. This process is for deliberately installing WordPress in a subdirectory (for development purposes) and then having it show in the root. You do not need to touch the database or “move” anything other than the index.php file.
For “migrating” WordPress, I recommend that people purchase BackupBuddy (http://askwpgirl.com/go/backupbuddy.php) which does backup the database and the files and allow you to easily migrate the site to a new server. It can also be used to schedule regular backups of the site to cloud storage or other FTP server. I’ll check out this free plugin, too! Always nice to know about these tools.
Thanks that is so useful! you saved me a massive headache in trying to update all paths in my database!
Yay!
Thank you, thank you, thank you! You saved me so much work. I am so happy I found your post. I tried to do this the hard way, and wasted hours. If only I had found your solution first!
Hi there,
Thank you for an excellent ‘how to’. As a new wordpress blogger, I was quite perturbed to find myself displaying my root www directory when I went to my site.
All sorted and working thanks to you.
all this work fine for me but you can see the sub-drectorty path when you go to log in. How can I fix this please
Thank you Angela. It took me all of 10 seconds to find your article in a google search, and now I’ve got a clear map on how to do the switch once I’ve got my blog set up (which was a migration from Joomla). Nice to know I can leave it in the subdirectory. Joomla was also in a subdirectory.
Actually as I write this, one question comes to mind. My Joomla site was in domain.com/site . I was intending to have wordpress in domain.com/subdir and then follow your directions for having it function with the root url domain.com. But now it’s got me thinking… would there be any advantage is actually having it in domain.com/site (the old Joomla location), obviously after I have decommissioned the Joomla site and removed it from that location?
Cheers,
Jonathan
Thanks. This is exactly what I need to do with http://www.mrmortgage.com.au This site is long in the tooth, but still gets a lot of visitors, so building the new site first in a subdirectory looks the ideal solution. Also great idea about hiding the WP install. I have had a site attack earlier this year. The host said that they had secured all their WP sites now, but this would be another layer of security.
Finally, one question about using sub directories for a multi product site using custom post types for each product section. I am about to use a listings theme with custom post types and a multi filter search box. For a niche site this would be perfect. But I am thinking of also making a multi product site, where the searches would be unique to each “custom post type” Is it better to use multisite for this, and how would I go about the install, and setting up the sub directories?
Thank you! I’m new to WordPress and .php, but I just wasn’t comfortable following the instructions at WordPress.org. I followed your instructions and it worked like a charm.
Angela the Angel – you completely made our day! Thanks sooo much for your clear, generous directions. We followed them, problemshot with your FAQ, and Voila! All is well at the new walterstrauss.com. Happy New Year to you –>>… Walter and Chris
Hi Charlene,
Two things:
1 – With this process, you will still login at the full URL that includes the subdirectory because the WordPress application is still located in the subdirectory. We did not move WordPress, we simply made the page and post links display from the root.
2 – To avoid having people index the subdirectory (ie to keep the subdirectory contents private), you need to follow step 7 on this blog post: http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/
Good luck!
I don’t think there is any advantage to having the site be in the old Joomla directory since all the URLs are going to be from the root anyway. However, you might want to use the WordPress Redirection plugin to redirect those old URLs to the new ones on WordPress. http://wordpress.org/extend/plugins/redirection/
Hi Grey, It sounds like you’re really on top of your content needs and thinking ahead of the curve. I don’t know if multi-site is the solution for you or not, but I think custom post types could be an easy way for you to go. Though it sounds like you want to limit searching to just within the custom post type of the product they care currently browsing. There are some forum posts on on WordPress.org on how to limit searching to specific custom post types, but then you’d want to create multiple searches. I’ve been using drop down taxonomies for something similar — so they can pick the “product type” they want from the drop down, and I have 5 different ways products are categorized. So you may need more custom taxonomies rather than custom post types if that makes sense. Good luck!!!
Yay!!! I’m so glad to hear that.
Happy New Year, Walter and Chris. Thanks for the greetings. Cheers! You’re music is wonderful. I love it! I volunteer with a West African dance/drumming festival and visited Ghana a couple years ago. I’m a big fan of Ry Cooder, and your music reminds me of his CD Talking Timbuktu with Ali Farka Toure.
Thank You…Thank You…Thank You…
Excellent, easy to follow instructions. This worked like a charm!
Awesome!
Angela I’m having problem with the permalinks they are still pointing to my subdirectory
Hi — Try to set your permalinks to the default and see if the pages work and let me know. Then, I can tell you what to check next.
Thank you for the nice tips . I have followed the steps in “How do I move WordPress from a subdirectory to the root directory?” and my pages still show url inside the subfolder. Do you know why? http://drangelebesner.com
Hi Walter. Looks like you didn’t follow all the tips exactly. Please read the post again and then perhaps read the FAQ and make sure you got it all step-by-step. Also check your permalink structure. Should not include the sub-directory name in that structure.
I am updating a site for someone who originally had another person working on it. He is not knowledgeable with website development. I have never used WordPress before this. Well, today I was playing with a URL change to just point to a different page. I went back afterwards to the General area and changed it back since it didn’t work. However, now I can’t access WordPress at all. I get the Internal Server Error. I don’t have access to the PHP area on my computer to change anything in the database. He doesn’t even have the WP install on his computer. I guess the previous person did all that. So, is there anyway for me to fix this or anyone who I can contact to do so?
You will need to get his web hosting control panel and FTP access to the site. Once you get the web hosting control panel access, you can login to phpMyAdmin which is an application you’ll see in the control panel. If it asks you for a password, you’ll need to have the FTP access to the site to find the database username and password in the wp-config.php file. Read the FAQ I have to this post for more information. Email me directly via my contact form if you get stuck. I charge $75/hour for support, and generally these issues are resolved in under an hour — usually 15-30 minutes.
[...] I wanted the front page to be at the root of the domain, so I skipped over to this other tutorial page. This one guided me through the process of redefining the root of the URL – a very nice [...]
Hi WPGirl,
I would like to change my existing site substantially but need to work on these changes while the current site remains up for users. The switch from current site to new site would need to be pretty seamless in timing. Is it right to assume a second wordpress install to a subdirectory is a good way to work on a new site while the current site is up?
Would your instructions above allow me to ‘move’ the new site in the subdirectory to the current/old sites url? Sorry if my language is fuzzy but I’m obviously a bit green here, hopefully you understand what I’m asking
With that said, where would the best instructions be found for installing wordpress into a subdirectory? I ask you simply because I want to make sure I set this up properly for your instructions!
Thank you for your time,
BDA
Hi Bobby,
Yes!!! That is exactly what I do for current clients. Right now, I am redesigning a site for a client, so I used BackupBuddy plugin (http://askwpgirl.com/go/backupbuddy.php) and I did a full backup of the current site, created a new blank database, and then ftp’ed the backupbuddy backup plus their importbuddy.php script to the subdirectory where I’ll do the development on the new site, then ran the importbuddy.php script via the domainname/subdirectory/importbuddy.php url.
The beauty of backupbuddy is that it will update ALL the links and URLs, so they reference from the new location of WordPress in this new subdirectory.
So, then after you’ve “migrated” your current installation using backupbuddy to the new subdirectory, you can do all your modifications. When you’re finished, you can follow the steps in this post to have the pages from this subdirectory installation display from the root, so you all of the URLs will match the URLs as they currently are on the old site with the exception of images, which will all link via the subdirectory URL.
The beauty of this process is that all of your image links will not be effected when you do the “move.”
So, definitely use BackupBuddy to get the copy of the current site duplicated in the subdirectory correctly — unless you’re basically blowing away the current site and are starting fresh.
Feel free to email me via my contact form if this is at all confusing. Once you’ve done backupbuddy migration a few times, you can do it in your sleep or like I do — in a sort of half awake over-caffeinated zombie like state.
Cheers,
Angela
Hi Wp Girl,
Currently my Wp develpoment site is in a seperate directory of the site root directory. The old site, which I will be removing, is in the root directory.
Your instructions are the most lucid I have come accross, but I found almost identical instructions at http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory, and there seems to be a conflict.
You say, “MOVE (do not copy) the index.php file,” and the other instructions say, “Copy (NOT MOVE!) the index.php.” In addition, the other instructions mention moving the .htaccess file to the root directory. Can you comment on this?
I could just experiment a little, bu I am fearful of digging a hle I can’t get otu of.
They suggest copying instead of moving, because when you move the index.php file from the subdirectory it leaves your subdirectory without an index file meaning that visitors can look at all the files in that directory. I have had best success with moving the file. If you copy it, people often edit the wrong file, try to access WordPress in a way they shouldn’t, etc. It’s just messy to leave a copy in the subdirectory.
After you MOVE the file, you’ll want put a blank “Silence is Golden” index.php file in the subdirectory so people can’t view your subdirectory contents. I describe how to do this in this post. You can find a “Silence is Golden” index.php file in the wp-content folder, the themes folder, and the plugins folder. It is in all of those folders to keep people from seeing the contents of those folders. If you open one of those index.php files, you’ll see some text that says “Silence is Golden.” It just is there as a non-displaying comment and results in a BLANK page being displayed when someone goes to the URL of that directory. Try it.
So, the wordpress.org instructions are not “wrong” per se, they are just not “correct” if you want to do things cleanly. I think they realize most people can’t handle too many steps in a process and don’t want to leave the subdirectory without any index file for security reasons. Make sense?
I’m just curious about reason #2 (extra security layer) as far as why you recommend placing WP in a subdirectory; wouldn’t it be as simple as copying the source URL of an image file on the site to realize where WordPress is installed?
Yes, true, but some bots are programmed to go to sitename.com/wp-admin or sitename.com/wp-includes. All the images are still viewable via the subdirectory, so it’s not a big “secret” where wp is installed, but can fool some bots looking for wp app files in the root.
This is a great guide. Worked perfect.
Thanks.
Hi Anthony, So glad to hear that!
WOW! This is awesome! It worked just like you said. Now, is it possible to move the ‘image’ directory by itself to the root to completely protect the location of the install? Thank you for all the help.
I did read a post somewhere (perhaps on Perishable Press) about being able to locate the wp-content and/or uploads folder to a different location, but it didn’t always work with specific plugins. So, I wouldn’t take the chances. It’s so easy for bots to find out “where” WP is installed, that it’s hard to totally obscure it and your site, if it gets hacked, is going to get hacked via a plugin or theme NOT WP core. The best you can do for security purposes is to be cautious about what plugins you install, keep everything updated all the time, and do regular backups of your database and wp-content folder using a plugin such as BackupBuddy (my affiliate link: http://askwpgirl.com/go/backupbuddy.php). Glad the process worked!
Angela, great post, really, thank you very much. You can tell how good a post it is by how many comments it receives WAY after it’s been posted! You wrote this a year ago people are making use of the info to this day! This guide really freed me up with a client; thanks again.
That’s awesome, Daniel. Thanks for the comment. I have been keeping the post updated since I wrote it, and also wrote an FAQ based on all the comments. It’s amazing how many hits it gets, and I know people get really stuck with this and have some urgency, so I try to be responsive. I might make a little video! I also am in the process of writing a post about how to migrate WordPress from one server to another using BackupBuddy.
Awesome! Thank you.
Thank you for the great post. I had a similar issue and helped me but now i see another problem. i cannot access my posts via the menu and get white/blank pages..any idea how to fix this?
Can I still tweak the site (the theme options, for example) and add pages and posts after I’ve gone through the process above?
Hi Lily,
Yes, it will work exactly the same as it does now. This simply allows the URLs to show from the main URL of the site, but WordPress is still in the sub-directory, so you will access WordPress via the same URL do now.
~Angela
Hey Angela, Thanks so much for the quick reply. I actually went ahead and did the process myself and saw that it is indeed editable. All went very smoothly, perhaps because i followed your directions to the letter. They are so well written. A million thanks!
BTW, I’m “Angelynn” and you can see my site now at http://angelynngrant.com.
I’m going to make a donation in gratitude.
Hi Angelynn. I love your site. Thanks for sharing. Glad it all worked out.
Hi Angela, Your way of explaining this process is fantastic, I have used it numerous times with absolute success. I have come across a problem with a site I am working on currently, within a plugin – Gravity Forms. All the internal hyperlinks, images, everything, works perfectly from the subdirectory install for every other plugin and image. Except within one area of the Gravity Forms plugin which is a link to a modal window from with the plugin dashboard. It returns the white screen (as as I have Silence is Golden running). If I don’t have Silence is Golden running then the sites index is listed. This modal window is meant to be a editing window, like a image edit window. I have been in touch with the Gravity Forms Developer, but they seem to think its the install? Have you come across any issue like this before? maybe have some tips?
Thanks so much!! This was the easiest tutorial to follow!
I would need to know your website URL.
Hi Amanda,
I use Gravity Forms on just about every site I create, and I’ve never had this problem. If you think it’s the Silence is Golden plugin, then de-activate that and just make a copy of the index.php file you find in the wp-content folder and put that in the root.
I don’t think the Silence is Golden Guard plugin should cause this problem, but I do know someone else who had some weird issues and we disabled it as a result.
Check over all your settings again just to be sure you didn’t leave a forward slash at the end of your URLs in the General Settings. Email me via my contact form at http://moongoosedesigns.com if you still have trouble.
I would perhaps suspect more greatly that you need to clear your browser cache and perhaps you should reinstall Gravity Forms — perhaps you updated it at some point and one of the files didn’t update all the way. One person who wrote to me had issues she thought were related to this “moving” process but were really because she had just updated a plugin, and the update didn’t completely properly.
You’re welcome!
Cool. Glad it worked.
Hi from Denver
I really appreciate your knowledge of WordPress - THANK YOU!
Nice to meet you, Brenda. I hope to write more soon. I’ve discovered some awesome WordPress themes that make development so easy that I’ll write about along with how to migrate WordPress to new host or from development site on a local computer to a new site, etc.
Angela
All I can say is… THANK YOU! I must have read every tutorial on this topic over the past three hours and no matter what I did, I couldn’t get it to work until after reading yours. It was your well-written, highly-stressed #FOUR tip that solved this problem for me. Because I named my sub-folder wordpress like so many people do, I was actually changing the /wp to /wordpress, instead of just adding it in front of the slash. Blame it on my tired eyes or maybe not paying enough attention, but you spelled it out so beautifully and made it easy to see what I was doing wrong. This was my first time designing a WP site to take over a client’s static html instead of starting from scratch, and I was already a little nervous about the process. With this info I will definitely be leaving the WP files in a sub-folder from now on to keep things nice and neat. Thanks again for making it seem less scary! I will be bookmarking your site to follow for the future!
)
Hi Shannon – That was the best written testimonial I’ve received yet! I’m glad that the highly stressed #4 was helpful. After receiving hundreds of comments on this post and helping people personally do this, I’ve rewritten the post plus wrote an FAQ, because I would see the same mistakes over and over again. It’s those simple things – like syntax – that can make things go wrong. I’m guilty, too, of “tired eye syndrome” and simply having a misplaced ; or ‘ in my code. Good luck! I’ll be writing more helpful posts over time.
You’re truly amazing. Thank you.
You’re welcome. I guess it worked!
I’ve got a lot of subdirectories on my site for forum and CMS applications and had previously linked to these from a static webpage in the root directory. This is so much easier and neater. I like the clarity of your instructions and the layout of the site.
Thanks for your work.
Yes, when you have lots of applications, it’s important to keep the root directory clean! Thanks.
Thank you so so much! This saved me so much time and now I am going to create all of my sites in a subdirectory. Do you know if I will run into any problems in I install a wordpress landing page in the root, and then delete all those files before I go to move the fully developed site from the subdirectory to the root? Thanks! I’m off to make a donation for your excellent help!
Hi Kimberly,
Thanks for the donation! You can use one of two plugins (see below) to create a temporary “landing page.” You’ll want to follow the instructions in this post first, though, so the landing page plugin works. Otherwise, it will just show up in the sub directory.
When you’re ready to go live, you’ll simply disable the plugin.
http://wordpress.org/extend/plugins/underconstruction/
http://wordpress.org/extend/plugins/custom-coming-soon-page/
You can try them each out and see which one you like better. I think they each allow you to specify a custom-designed html page or have options for styling their landing page.
Thanks so much for that advice. I will take that into consideration on future creations. For my current site, however, I already installed a landing page plug-in at the root (along with a wordpress install), but I am working on my actual site on a subdirectory. I’m wondering, is having an install of wordpress at the root going to cause any problems when I go to make the transfer? And do I just delete all the files in the root at that time to make the transfer? A little clueless. LOL.
BTW, your advice from this blog post worked beautifully for a site I was just working on for a client!
You are so smart! For the site where you have WP in the root and WP in subdirectory, you’ll want to delete the WP in the root and then follow the steps in my post.
You might have to go to Settings > Permalinks to save those again so the .htaccess in the root gets reset properly.
Glad everything worked out with the other site! The only problems I’ve seen are with extenuating circumstances — such as Windows hosting server, mistakes, and people leaving their old files in the root.
PERFECT! Easy to follow instructions that Ditto shannon.
I do have one issue, which began on my first attempt at this from another person(ugh) None of my images are showing up. The place holder is there and the link at the bottom display the original path to the image but no workie
Any suggestions?
Hi Maria,
It’s hard for me to say what the problem might be because of someone else having gotten in there, and we don’t know what they did. You can read the FAQ I wrote on this process, but I’d probably need you to send me the URL to the site, so I can see what’s going on. Are you still accessing WordPress via the sub-directory? What are the URLs to the images?
You are a life saver…so far! I’ll check back in 10 minutes to see if it’s still working…
Your directions are VERY COMPLETE and easy to read. Thank you!–Ana
Cool. Fingers crossed!
Excellent, straightforward steps. Something I was worried would cause me a headache was completed in a few minutes thanks to these instructions.
Yes, any other method is painful for sure.
than you so much, this guide just saved my day
Yippee!
Thank you for this post. I carefully followed the instructions and got it mostly working first time. I was using it to convert an old static site into a WP site, and I wanted to learn how to install WP in a directory.
My problems came from the fact that I use Hostgator. The site would not work internally with WP generated .htaccess file not in root (public_html). But when you move it to root it still has the reference to the installation folder in it. I edited in TextWrangler and uploaded it to the WP subfolder then copied over the top of the generic .htaccess that is created by the hosting. Bingo, everything worked.
I tried the silence is golden plugin, I must be dense because I could not get it to create an an index.php for the the WP folder, but it seemed to create one everywhere else. I ended up just doing in TextWrangler and uploading using my host’s file manager program.
Overall, a good experience, and I think I will do all my WP fresh installs in directories, not in root. Thanks.
i want to have my site which is installed at http//www.optimasystems.ca/security_division wordpress is installed in this location as well as my theme. it works prefectly but i want it so that when you type http://www.optimasytems.ca it shows the new wordpress site in the security_division folder
Your instructions seem so simple but i keep getting
this:
Not Found
The requested document was not found on this server.
so i changed the index.php file to this
———————————————————
this index.php file is a copy which was in the folder security_division
i also changed my general settings to:
WordPress Address (URL) http://optimasystems.ca/security_division
Site Address (URL) : http://optimasystems.ca
so i belive thats all i have to do but it’s not reading anything.
i have the old site up and changed the index.htm file to indexold.htm just so it wouldnt get confused . i put it back because the owners woulud freak if they see no site up.
Hi Angela, I have a different problem that I hope you might be able to shed some light on? When I first installed wordpress I did so on a subdirectory. Thinking I knew what I was doing I then copied this folder to my root to make this my websites directory. As your post so eloquently illustrates this did not work. So I resumed using the subdirectory as the root of the site. The site has grown in time and uses many plugins. I now want to consolidate the site and get rid of the extra files that were made by my previous attempt. The thing is, the site seems to use some of these files. So when I delete these extra files on the root of the server it breaks the site, even though the sites root is in a subdirectory. Is there a way of finding out which files the site is using in this directory, so that I can consolidate the site and then move it using the method you have written?
Either the site is in the subdirectory or it is in the root. Now you say you have files in both the root and subdirectory. That doesn’t make any sense. WordPress will look in one location for the files, so you should check your Settings > General in WordPress and see what those are and write back. Also, see what is in the index.php file. Why are there any files in the root if you moved them all back to the subdirectory?
You have the site installed in a subdirectory and when you to go the root URL you want it to REDIRECT to the subdirectory, so you really DO NOT want the URLs to display from the root, you want them to all display from the subdirectory and when you go to the home URL you want it to show the subdirectory not the root URL? Correct? If that’s the case, return your Site Address (URL) back to how you had it with the subdirectory name and then use .htaccess at the root to redirect the root URL to the subdirectory.
You are doing the opposite of what most people want to do, so you should not follow any of my instructions in this post and instead leave everything in the subdirectory and use .htaccess redirect the root URL to the subdirectory URL.
Most people want to get rid of the subdirectory in the URL and show all the links from the root, so that’s why my post is not helpful to you.
Hi Christopher,
I use HostGator a lot. The issue with the .htaccess is easily resolved by going to Settings > Permalinks and clicking the Save Changes button. This automatically rewrites the .htaccess file after you’ve done the “move.” This is not a HostGator specific issue. It’s more that sometimes your .htaccess needs to be rewritten and the simple Save Changes on the Permalinks page will do that on good hosts such as BlueHost and HostGator.
Good to know about the Silence is Golden Guard plugin. I assumed it created an index.php in the WP directory, but if it doesn’t then I shouldn’t recommend it here and instead people should just download the blank index.php file from the wp-content and upload that into the WP directory — or WordPress recommends copying and not moving the index.php that’s there.
Hi, I am working on a new wordpress site that I will eventually move to my main domain name to replace my old static site. Your instructions on moving it are very helpful, except I have one problem: I can’t find the line any where, on my index.php or on any of the index.php files that are with some of the included themes. What do I do or where do I find this?
Please disregard my last question about the index.php file. I found the answer, I was looking at the wrong index file before. Thank you.
Yes.
Thank you! After hours of trawling through numerous over-complicated instructions and laboriously undoing all the changes I had made when they didn’t work, I came across your clear instructions which made sense, and worked first time. However, I still have a couple of problems………
My links to uploaded media files such as pdf files were broken and I could only get them to work if I manually re-inserted the subdomain name into the link realtive URL. This worked, bit is there another tidier way to restore these links?
More importantly, in my subdomain I had a plugin called Exclusive Password Content Protect which hides certain content unless a password has been entered. The password entry box still shows, but entering the correct password achieves nothing. Any suggestions?!
Hi Henry,
Not knowing what you may have done or not done to break your links, I can only say that:
1) This process will NOT break ANY image or uploaded file links.
2) If your links are broken, it’s because of something you tried to do previously to “move” WordPress and perhaps rewrote your links in that process.
3) If WordPress STILL resides in the subdirectory, then all of the images and uploaded file links should still contain the subdirectory in the URL, eg.
http://askwpgirl.com/subdirectory/wp-content/uploads/mydocument.pdfAs far as the plugin again, the same applies there — it should work fine but some plugins don’t have the paths defined correctly and insist on looking for WordPress in the site URL rather than WordPress URL, so that would need to be changed in the PHP code of the plugin if that’s the case. You can Google that plugin and see if people have issues running it from a subdirectory. Cforms has this issue as well.
Thank you for your prompt response.
After a bit of googling I found the relevant WP Codex page (http://codex.wordpress.org/Linking_Posts_Pages_and_Categories) to say “If you have installed WordPress to a subfolder, such as wordpress, don’t forget to add the folder to the link URL”. That is precisely what I have had to do, so perhaps I’m stuck with it!
Cforms survived the procedure with no problems despite your dire warnings. I’ll investigate further about the password plugin, but maybe I’ll have to abandon that one.
Many thanks; great post!
When you follow these procedures, the URLs for categories, posts and pages do NOT include the subdirectory. However, when WP is installed a subdirectory, as I wrote before, all of the images and uploaded files DO need to include the subdirectory in the URL, because the wp-content folder has not moved — it is in the subdirectory.
I should add that for people who follow these instructions precisely from the beginning and haven’t done other things previously to change the links on the site, then they do not have to worry about any links being broken, except for manually created internal links to pages or any custom links in the Appearance > Menu.
Thank you for these tips! I moved everything over and followed your instructions. The landing page loads fine but the interior pages are not showing. I move the .htacces file to my root. I opened up my .htaccess file and there’s nothing in it. It’s file that was installed with WP by my host. I guess there should be some redirection code in there but I’m not sure what if anything. Thanks for any light you can shed on this.
found it further down on your blog. my .htaccess file wasn’t writable and I had to save it manually. i all works. thanks for your WP mojo!
Angela – as always, thank you for your simple instructions
I was able to get this to work on a site of mine before, however, the WordPress contents interfered with some ASPDotNetStorefront contents, so it was either/or (by switching out .htaccess files)
However, we have now MOVED all of our ASPDNSF contents to a subdomain/subdirectory “store”, and the root is completely clean except for 4 directores
And now I want to complete my original intention of having my WP contents show up as domain homepage and normal pages
I got the homepage to load, and nav links are written correctly (without the /subdirectory/ showing in the link)… BUT I get the “”The system cannot find the file specified”" error when clicking onto navbar links to inner pages
I made sure to MOVE .htaccess over from subdirectory to root, and to re-save my permalink settings, but no go
Im thinking it has to do with me not doing exactly how I first tried (when successful) and possibly regarding COPYING vs. MOVING the index.php file and/or the .htaccess file
Just to be sure, I am supposed to essentially have TWO index.php files, one at root and one inside subdirectory where all wp contents are… correct? and with that, should those index.php files be identical? Im guessing they shouldn’t since your instructions say to download original, edit, then upload edited to the root – so it should be like this right?:
index.php in root should read:
require(‘./blog/wp-blog-header.php’);
index.php in subdirectory should read:
require(‘./wp-blog-header.php’);
I also tried the Silence Is Golden index.php within the subdirectory – still no go
I also tried having the .htaccess file BOTH in the root and subdirectory, made sure to update permalinks settings. Nothing.
Any ideas?
It might be something entirely different, being as this is a clients site hosted on a Windows host (booo! but he is running .aspx so must)…might be something else interfering
However, I was able to get it to work BEFORE, when the aspx stuff was at root, so I figured that after moving it to subdomain and root being clean as a whisle, that the WordPress would work perfect
thanks so much for your input
Hi Jesse,
Are you hosting on a Windows server? It sounds like you are if you’re also hosting an ASP store. If you are on Windows, you will need to contact your web host about how to manage the permalinks, because .htaccess with the rewrite mod is an Apache server function, not a Windows server function. If you read my FAQ which is linked at the bottom of this post, I do have some info about Windows permalinks on there.
Awesome. I never knew it would be so easy
I have been looking for an answer for my question and I think I found it or near enough but need some clarification first. Right now I have a static html site that I host on Hostmonster and currently use WordPress for my blog so it’s already installed. I would like to remove all the old files and create a new website in WordPress (all new pages, nothing from the old site will be kept) but keep the blog content as my blog. I have installed a new theme and am ready to design.
When I am ready for my website to go live I will remove the old html pages from the root directory, follow steps above to move WP from sub to root directory and deactivate the maintenance plug-in. All things being equal everything should be cool. Since I am moving WP to the root directory will my blog still be my blog and my website be my website on the WordPress platform? Or do I need to do other steps?
Hi Grace,
Is the only WordPress you have installed the one in the sub-directory? It sounds like you might have two WordPress installations. Please let me know then I can advise you.
The easiest thing would be to just use your current blog WordPress installations and create the static pages on that installation of WordPress using the new theme, etc., but then, if you’re using the maintenance mode plugin, people won’t be able to see your blog. That’s why it sounds to me like you are working with two different installations of WordPress.
I think you might be right. Under the public_html there is a blog folder that includes wp-admin, wp-content and wp-includes.
In the public_html/RedBarn-Studios folder (where my current & soon to be old website files are) there is another folder called blog_2. If I remove this whole folder (RedBarn-Studios ) completely I assume that the blog pages I have designed will be deleted as well?
Hi Grace,
I don’t know how to advise you at this point, since I don’t know which WordPress install is being used for your content, and it actually sounds like you have 3 copies of WordPress installed. If you want to hire me to sort this out for you, I can be reached at http://moongoosedesigns.com. Do you have two or three WordPress logins you are using – one for each of the sites? If you do, you need to pick the one you will ultimately be using for the live site, and login to the other one that contains your posts and go to Tools > Export and export all of your post content and then go to Tools > Import on the version of WP you want to use when you’re all done with your development and import those posts, so you have everything in one place. Don’t delete anything until you’re positive you have ALL of your content in the correct WP install. I have seen people do this before. They sort of get carried away with the one-click installers at their web host and forget all the places they’ve installed WordPress as they attempt to development work on a new site.
On my win2003 server with PHP5, I was getting a white page for my blog until I changed the line in the index.php file at the root of my site (not the index.php file in the blog directory) to the following: Note the deletion of the “./” right before “mywp”. It’s working great now.
Your text got cut off in the comment, so I don’t know what you changed your index.php file to, but yes, you are supposed to edit the index.php file in the root of the site not in the sub directory. The copy of the index.php in the subdirectory doesn’t have a function after this process has been completed other than to prevent reading of that directory.
I have never seen the index.php work properly without the ./ before the sub-directory name. That wouldn’t make sense in a normal hosting environment. Here is what the require line is supposed to look like (where blog is the name of the subdirectory):
‘./blog/wp-blog-header.php’
So, interesting that yours is working as:
‘blog/wp-blog-header.php’
on your server. I would think that would break it unless there has been a typo to begin with. I don’t know anything about Windows server hosting. I usually recommend people avoid hosting their WP on Windows because it usually results in a lot of problems, including difficulty with permalinks and plugins.
Hi,
help!!
Thank you for the above instrusctions. They’re detailed and will certainly assist me. However, I seem to have ‘lost’ my old static site. It’s no longer in the public_html folder but somehow is still live.
Thanks
Bonnie
I don’t know what you mean be “is still live.” Does that mean you’re finding it in a Google search or you see it when you visit the site in your browser window? Have you tried deleting your browser cache? It will take a few weeks for Google to re-index your site and no longer show the old page URLs. It helps if you install the Google XML Sitemaps plugin and submit the sitemap via Google Webmaster Tools.
THANK YOU, THANK YOU, THANK YOU!!! If it weren’t for passionate individuals such as yourself… where would we be???
Your assistance has been greatly appreciated!! Bonnie
Thank you very much! This is exactly the information I was looking for!
this is still very complicated, compared to what was said about moving one file, one line of code and one modification! I might need someone to hold my hand while I do this because those instructions are foreign to me lol
This is exactly what I need to do, except when I try to do it, I am getting the following error when I load the main “mysite.com” page:
“Warning: require(./wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home/hihp0312/higherhopechurch.cggc.org/index.php on line 17
Fatal error: require() [function.require]: Failed opening required ‘./wp-blog-header.php’ (include_path=’.:/usr/local/lib/php:/usr/local/php5/lib/pear’) in /home/hihp0312/higherhopechurch.cggc.org/index.php on line 17″
There was a previous Joomla installation and there is no www, htdocs, public_html, or httpdocs folders that I have unearthed after hours of searching. I thought I had the file in the right root directory, but perhaps I don’t. Any help you can provide would be immensely helpful. Thank you.
Hi Jen,
You may have missed a step. Please read the FAQ for this blog post and check that you edited the index.php file correctly after you moved it to to the public_html directory. Please reread the instructions carefully. The error you are getting is related to the index.php file not finding the folder in which you have WordPress installed, and the require line must be edited correctly according to the instructions in the post.
Thank you soooooo much! I have followed your instructions and all worked well except I can’t get the home page navigation link to work. Have installed plugin, looked over code and still can’t make it happen. Any thoughts would be very much appreciated. I was in Boulder for the last Word Press Camp there. Enjoy your day, Bob, up the road in Lander, Wyoming
Hi Bob,
The home page link is either set in your theme’s header.php file OR more likely under Appearance > Menus. So you probably want to remove the Home like you created previously for your custom menu and add a new custom link to the home page and save your menu.
great tutorial, thanks!
Hey this is brilliant, however i have another question
i have a wordpress installed in a subfolder and i have an HTML file in the root which contains flash site, i then i have a link in there which points to the wordpress site which is in the subfolder
i want to be implement this same thing as above while maintaining the flash site in the root
is it possible
Thanks
Antony
Hi Antony,
That’s a great question. So, you want to display all the WordPress URLs from the main URL but keep the Flash in the root, correct? The main issues I would see with this are:
1 – Is the Flash file invoked via an index.html or some sort of index file that would conflict with the WordPress index file?
2 – Is the Flash file the landing page for the domain? If it is, then having the WordPress index.php file in the same directory may conflict.
3 – You said the Flash site points to the WordPress which is in a subfolder. If you resolved 1 & 2 above, then you would need the Flash link to point to the new URL for the WP page you are wanting it to go to after following the steps in my post.
You could certainly backup your WP site using a plugin like BackupBuddy (http://askwpgirl.com/go/backupbuddy.php – my affiliate link) and then try the steps in my post and see if it works. Not knowing the name of your Flash file and whether that is the home page of the site is a bit tricky. However, being a resourceful person, I would follow the instructions in my post, then create a blank php page template within WordPress (eg page-flash.php) and assign this page template to a new page in WordPress called “Home” or “Splash” and choose this as the Static Home Page under Reading Settings. In the page-flash.php template, I would put the code to launch the Flash.
If you don’t know about creating custom WordPress page templates, this might be Greek to you, but it would be one way to keep the Flash functioning and WordPress at the same time from the root, by incorporating the Flash into the WordPress install. It won’t change the look of the Flash, it will just make it behave from a URL standpoint properly by being an object on a WP page (that is — a totally blank WP page so it doesn’t disrupt the look/layout of the Flash).
thanks for your response
Hey the flash file is evoked using the Default.html file, which has precedence over Index.php right ?Yes the Flash is the landing page for the Domain, the landing page has an enter here which redirects to the wordpress site, the URL for the link is given as wordpress/index.php
so i should be able to do your procedure as long as i have the landing page as default.html and of course i have to point the enter here to /index.php right ?
if you want to have a look at the site here it is
http://shalimarthailandplants.biz
I’m not sure if the default.html will conflict with the index.php. I think it will, that’s why I would personally create a page in wordpress called “home” or “flash” and make this the default home page for WP under General settings, then create a custom page template that basically has the contents of your default.html page on it. If you want to hire me to set that up for you, I could.
you might be right, i default.html does conflict.
i am going to try the custom page template, if i fail i shall get back to you.
thanks WPSupergirl
hello, I also have WP installed on a subdirectory (www.websiteaddress.com/WPsubdirectory). I have created a multisite network and am trying to create a new site at http://www.websiteaddress.com. I am only able to create a second site if I create another subdirectory under http://www.websiteaddress.com. What am I missing? I can I create a site at the root directory when WP is installed on a subdirectory already and powers a website under the same subdirectory. I am new at this so perhaps this is bad design to begin with…Please redirect me gently
Thanks
Hi Joelle,
It is not clear to me WHERE you have created your multisite network and what you are trying to accomplish or how you have your multisite set up. Multisite is very different from the regular WordPress and the multisite network could interfere with your installing other versions of WordPress in other locations if the URL relates to your other networked site URLs. Also, multisite will NOT work installed in a subdirectory and redirected to the root. For multisite to work properly for subdomains, it should be installed in the main URL of the site.
Thank you. You made this so easy!
Your post really solve my problem.. Thank you very much!
Thanks for the great tutorial! I was having an issue where all pages but the home page were showing up. I read through your FAQ page, and the culprit was some old index.html files alongside the index.php. I archived the .html files, and everything’s working now.
I appreciate your great work.
Hi I had a site in a subdomain, thought or read that you should just change the site url and the wordpress url to the main domain, did this thinking I could change it back if it didnt work, now the site has many 404, and links and theme template has disappeared completely.
Can it be rectified, or do I, or should I un-install it and do a complete rebuild.
http://aikidoports.aikidoinportsmouth.com/
Cheers TOny
Hi Tony,
My instructions apply ONLY to WP sites installed a sub DIRECTORY or sub FOLDER, not a sub DOMAIN. Subdomain works differently and will not work following these instructions. To restore visibility and access to your site, you will need to login to your database with phpMyAdmin and modify the URLs for the site and the home (see the FAQ for this blog post) and change it back to your subdomain URL for both.
To have your subdomain be your main domain, you can ask your web host to point your main domain DNS to the subdomain directory, then change your General Settings to use the main domain url in both fields and use the Search & Replace plugin to replace the old subdomain URL with the new main domain URL for all the uploaded image content and internal hyperlinks.
Thank you WpGirl
I see the error of my ways ha ha, thats a big help, thanks for your advice and time,
will try what you suggest and see what I can find
Cheers Tony xx
Hi Tony – I should definitely emphasize that at the top of the post and perhaps write another post on the subdomain transition. It’s a bit challenging, because web hosts handle subdomains differently.
Angela,
That worked absolutely perfectly. Thank you for taking the time to write this tutorial. Well-done, complete and easy to follow.
Thanks.
- Troy
Hi Troy, Glad that worked for you!
Hello, thanks for your info it is very useful. Right now i am finishing my website redisgn using wp which is installed in a subdirectory (while the old non-wp site runs at root). As you mentioned, keeping the site under a subdirectory has a lot of advantages, but does it have any negative impact in SEO? Is it worth in SEO terms to move the site back to root instead of keeping it at a subdirectory? Thanks a lot and regards from Mexico!
Keeping the WordPress installation in the subdirectory while having all of the posts and pages displaying from the root directory does not impact SEO because the pages and post URL all display from the root. Only the WordPress application functions are in the sub-directory along with the uploaded images. After you go live with your site, install the Google XML Sitemaps plugin and the All in One SEO Pack (which should have a sitemap built into someday soon) and get those setup properly. Sign up for Google Webmaster Tools and submit your sitemap. You might want to install the Redirection plugin to redirect your old site URLs to the new site, though I recommend turning off the option in the plugin to Monitor WordPress Posts, because that inevitably causes crazy issues.
EXCELLENT! Very easy to do and works like a charm! Happy Dance!
Every now and then, it’s nice when things aren’t hard.
Thank you WPGirl for making something less-complicated…
Great! All fine except that the images do not show up on my pages.
I can see the img src is set in the root directory, but the images are in wordpress directory.
Any clues on how to fix this please?
Thanks so much, this is exactly what I was looking for.
When using my instructions, you do NOT change the img src location. The reason this process is simple, is because the image links do not break. However, if you manually changed these, then they will be broken. The images still exist in the wp-content folder that still exists in the subdirectory. So the url to the img src should include the subdirectory.
Hi. I have default WP installation. With no content other than the example content. It was installed by default in /wordpress. I want to move it the root of my domain. I have the index.php file correctly changed. I have the .htaccess file with the correct information in it. Yet going to my domain site http://www.anlarye.net I am prompted to download a file named ~ and nothing more. Everything that I can see appears to be done correctly.
It looks like you got things up and running. I would recommend BackupBuddy plugin for reliable backups. Here is my affiliate link: http://askwpgirl.com/go/backupbuddy.php
AskWPGirl – you are an amazing find! Thank you so much for this easy to follow guide – you saved me hours of frustration and fright!
I followed the instructions above however – I seem to be having an issue with a link.
I did a trial run of the migration (changing from paulsonbrothers.com/wordpress to paulsonbrothers.com). Everything looked great, except … when i click on OPTIONS in the menu, it takes me to the correct page, however, when i try and click on any of the other menu options (BATH, KITCHEN, etc) it errors out with ’404 PAGE NOT FOUND’ i did notice for some reason it wants to reference the original link; paulsonbrothers.com/wordpress. is there a way for me to fix the link? i did update the permalinks – but this did not fix the issue. thanks so much for your help!
Did you copy or move the index.php file to the root directory for the site and modify it per the instructions I sent? If you did not do that, then the URLs will not work. You have to follow all of the steps in the post. If you skip a step, then there are problems. Also, your .htaccess file may need to be moved to the root as well. On one web host I work with, the URLs give 404 Page Not Found if the .htaccess is in the subdirectory. Check the .htaccess to make sure it doesn’t contain the subdirectory in it. Also, you will need to get rid of the current pages on the site so they don’t conflict with the WP urls. You can’t have both index files in the root. So, please follow these steps, then if you want to hire me to help you, please contact me via my contact page at http://moongoosedesigns.com. Good luck!
This worked for me:
1) Using FTP, copied index.php to my computer, then copied index.php to the root directory of site – /web , in my case
2) Under dashboard//settings/general:
WordPress Address (URL) - left ‘as is’, pointing to /web/wordpress folder
Site Address (URL) - changed to site homepage (different from WP folder files)
Had issue with site still pointing to old home page.
3) Renamed index.hm to old-index.htm – it WORKED!
(index.htm is first place that code looks to establish home page, so this MUST be renamed so index.php can be accessed first)
Minor wp-admin issue occurred – could not login to site, so had to add /wordpress/wp-admin to site name for site updates (wp-admin file is still under wordpress files, not root directory) Will leave this way for the time being.
Thanks WordPress Girl – this was a big help!
When you login after completing my steps EXACTLY, then you will ALWAYS still login via the URL that is the sitename/subdirectoryname/wp-admin because that is where WordPress is installed. As part of this process, you do NOT MOVE WordPress, you are simply having the URLs for posts and pages display from the root instead of the subdirectory. All the images, uploaded files, themes, plugins, wp application, etc. are still in the subdirectory. Does that answer your question?
How can I upload a new theme to my multisite wordpress-Always come up error/css style missing. I also tried uploading to my filezilla. still doesn’t work. Please help. I really don’t know, what to do. Thank you.
Make sure that your actually uploaded the full theme folder rather than the zip version of the file or the full theme files rather than just the actual folder containing the theme. What theme are you trying to upload? You should see an index.php, style.css plus other files in that folder.
Make sure that your actually uploaded the full theme folder rather than the zip version of the file or the full theme files rather than just the actual folder containing the theme. What theme are you trying to upload? You should see an index.php, style.css plus other files in that folder.
Thank you very much! Your a life-saver!
THX this worked out (and with having to do the .htaccess and permalinks). However, I have a few “private” pages so they dont show up in the main menu as parent/childs and text linked to from pages (to “read more” type of thing). Under the new naming redirect (to main root like other pages) these show up as “not found” pages, but you can see them if you manually type in the ‘old address’ with the subdirectory (i.e. dev.sitename.com/private vs. sitename.com/private). I appreciate your time.
I just wanted to say THANKS for these clear, easy to understand instructions. I am no web developer, but manged to follow these instructions and get my site working in the right directory. Thanks for the help & advice!
thank you, thank you.
Hi, just curious if the big three search engines (I.e. Google, Bing and Yahoo) have an issue with my pages remaining in a sub folder for indexing? I use Yoast SEO plug-in and find it quite handy. What do you think? Thank you.
Oh wow!! Very easy and so awesome!!! Thank you!
Thank you WordPress Girl! Your instructions are clear, precise and accurate-
much needed in a geeky world where the English language is not often used well.
John Parulis
LOL. You can thank the great training I had at Quark as a technical writer. Though, many are too young to even know what Quark was/is. Back in the mid-90s, it was an awesome place to work, and I got lots of practice writing the post-release tech notes.
Hi, I thought I sent you a question, but perhaps it didn’t go through. I’m about to install wordpress in a sub-directory and want to know for SEO purposes if it matters if wordpress is installed in the root or a sub-directory. Obviously we want as best a chance to rank high in Google and will use Yoast SEO, so does the directory matter? Thank you!
Hi TB,
Sorry for the delay in response. I responded to another very similar question recently, so I thought I’d already responded. Since all the URLs display from the root and the links to all your posts and pages are root level links, I don’t see any SEO disadvantage. The only items from an SEO perspective that are linked via the subdirectory are the images and uploaded files.
There was an interesting article on canonical URLs and a WP install in a subdirectory: http://www.wealthydragon.com/2009/04/22/all-in-one-seo-pack-pagerank/
To quote this article:
“The reported problems seem to have been caused where the WordPress files and the public URL were in different directories.
“In these cases the canonical URL feature in the All-in-One-SEO-Pack apparently gave priority to the URL including the sub-directory in the address – which confused the Google Bots and led to problems.”
However, in the example I have and write instructions for, there are NEVER any URLs served up from the subdirectory, so I don’t see how the Googlebots would be confused as this person says. Also, this article is 3 years old. From my understanding, the install in the subdirectory with the URLs being served from the root following my instructions is purely for convenience, and I’ve never heard of SEO problems with it (other than the article cited above, which doesn’t make much sense to me). Many people want to keep their directory structure clean, and this achieves that.
Thank you for the quick reply!
Nice – thank you!
Hello WPGirl, thanks for the great info. You make it sound so easy. I guess everything is once you know how to do it!
I originally created a website via a bludomain site and added my blog to it at /blog. Now I want to switch to Photocrati which is a site plus a blog. Of course the blog is also at /blog so how should I adjust the above directions?
TIA
Carlos
http://WeddingMedia.net
Easier than the way I did it in the past! Thank you!
This process has been problematic for me. I figured out that the Security Plugin I installed is the culprit. I believe that it overwrites files in an incompatible way. Anyone else have this problem, and/or have a workaround?
Hi Jamie, Which security plugin? I know the Silence is Golden Guard is problematic, so I won’t be recommending that any longer.
Better WP Security. It does include a Silence is Golden Guard. I’ll look into that.
Silence is Golden Guard wreaks havoc with WP installs in subdirectory and totally breaks the site, so don’t use it. There are so many security plugins, that I’m not sure really help all that much. The ones I find useful:
1 – WP Security Scanner — use once to check your file permissions then delete
2 – Firewall 2 – run all the time
3 – Limit Login Attempts
Good to know, thanks!
Thanks again for the recommendations. A couple of those haven’t been tested on the latest version; I’ll use what I can, but stick with known quantities.
WP Girl. (Reminds me of Word Girl on PBS my dauthter’s heroine)
I’m not sure if you missed my question above.
Hi Carlos, Your comment last month never appeared in my queue. Strange. I think it must have been a Disqus glitch. Anyway, per your question, Photocrati is theme, and what it sounds like is that you now want to use WordPress for your entire site rather than for just the blog. It is a bit problematic having the word “blog” be the subdirectory name, but you just have to be sure NOT to name any categories or pages “blog.” There are many ways to slice this. One is that you can install the Photocrati theme on your current blog and set up all your pages in your current WordPress installation, then follow my instructions to have these show from the root. However, all of the URLs for your blog posts will be changed. The URLs will no longer contain “blog” in the URL. So depending on how many inbound links you have coming to your site vis a vis those URLs, you may not care about that. The other option would be to install a new installation of WordPress at the root and then use the Tools menu on the old site to Export the old posts and then import them into the new site in the root. Either way, the URLs will be changed, since they will show from the root and not from “blog.”
In terms of the word “blog,” you will have a page on your site called “blog” but you’ll want to make sure the SLUG (aka permalink) is something other than “blog” – such as “photo-blog” or “my-blog.” So you will create a new page with this slug, and the page title can be Blog and the slug will be “my-blog” and you can set the Reading settings to show your latest posts on this page. Photocrati may handle things a bit differently, but typically people have a static home page with images and a separate “blog” page for the latest posts.
Thank You so much for your excellent answer to this question! I’ll be working on this as soon as I put out some other fires.
Thank you a lot! Very helpful. Far better than org procedure! I messed up my site with wordpress.org explanation. But with this, I manage to do it very easily and neatly and successfully! Cheers!
Yay!
Okay – I tried this. I edited the index.php, change the settings in the WP control panel, but got an error. I did not move the .htaccess file to the root. Could this be the problem?
The site is currently at uupoconos.org/wp
Thanks for any and all help!
Looks like you got it to work.
This seems to be exactly what I was looking for, I just want to make sure that all pages will move too, like mysite.org/wpinstall/about-us/ will move to mysite.org/about-us/?
I’m sure this is a rookie question, but what the heck.
Thanks alot for the great info!
Yes, the page URLs will no longer have the wpinstall in the URL and will display the same way as if you had installed WP in the root to begin with. Good luck! Read the FAQ if you get stuck or contact me.
Wow, after worrying about doing this for weeks, it was almost anti climatic it went so well. You rock!
Thanks again,
Matt
Brilliant and clear explanation – many thanks
Worked like a charm. THANK YOU!
You’re a genius WPGirl! I was dubious about building in a subdirectory then changing to root when it was all done after reading the ‘official’ version of how to do this. Then I found your simple instructions, which gave me confidence as a WP newbie, to go ahead – and it worked a treat. Thank you so much.
Thanks so much for your clear explanation. This made it super easy!!!
Hello,
I am about to move my wordpress to the root directory, then I read your explanation and the comments below and found that is easier than WordPress.org process.
Before doing this, I have one question. I have some .HTML web pages that has the same design as my wordpress theme. This is why these pages contain links to posts in wordpress (http://www…..com/wp/example-of-post/). Should these links stay the same in those .HTML pages after moving wordpress? Or should I change them to http://www….com/example-of-post/.
Thanks a lot for your help!
Make sure none of your HTML pages in the root have the same name/url as any WP pages. Then, yes, on those static HTML pages, you’ll want to edit the URLs to your WP pages to NOT include the subdirectory in the URL.
Thank you!!! Worked like a charm!!
YOU JUST SAVED MY LIFE– Was about to follow some crazy manual procedure offered in another forum…. This was smooth & easy! Thank you so very much for the excellent tutorial!
Hi, wonder if you are able to help. I wish I had stumbled on your post before starting. I have my wordpress running on my public_html. Is there any way of moving them to a subdirectory now? Reason is i am running my website on wordpress and now want to add a blog page. But I’m not having any success. I have a blog post and have edited the static pages in my options setting to the blog page. Now when i go to http://www.sitename.com/blog i can see the page with all the css etc and menu but no posts? Any help much appreciated. Thank you. Naz
Hi Naz, It’s hard to determine what might be the problem here. When you have a HTML files in the same directory as WordPress, you have to be careful to not have the HTML files be the same name as any WordPress pages, posts or categories, because that can confuse the server as to which content to display. However, if you don’t have static HTML pages in your public_html folder, then there is no reason why you can have a “blog” page on your site and set your Reading Settings to use that page as your posts page. If this is not working for you, then there may be an issue with your Theme. To test this, try to enable the default TwentyEleven theme and see if it works with that.
Hi! You have NO idea how useful your post was to me!
When I saw WordPress’s own description, I was ready to give up trying to make the /wp disappear! O_O It is THAT bad.
However, I followed your pointers, and as a so far ~5 hour long user of WordPress or any sort of website creating anything, it was easy to follow and figure out!
Unfortunately my site was the kind that needed to move the .htaccess file as well, and it took me a while to figure out why I wasn’t seeing it anywhere: it’s a hidden file! Have to make it visible first *lol*
So anyways, thanks for the awesome description!
It worked! Thank goodness for this post.
Remember that your login and registration links will still be http://www.yoursite.com/mywp/wp-login.php.
what if we want the login and registration links to be http://www.yoursite.com/wp-login.php as well ?? HELPPP !! thankssss !!
If you want to login to WordPress not using the subdirectory URL, then you need to MOVE WordPress into the root which is a different process than I what I describe here. I think the best way to do this is by using BackupBuddy plugin – my affiliate link is http://askwpgirl.com/go/backupbuddy.php
They have great video tutorials. Or you can follow these instructions (which might result in more broken things than using BackupBuddy):
http://codex.wordpress.org/Moving_WordPress#On_Your_Existing_Server
You could also add in a RewriteRule in .htaccess.
I’m wondering if the RewriteRule in .htaccess would create problems since WordPress actually lives in the subdirectory and all of its application files are there that will be sought in the subdirectory.
Thanks! This really got me out of a pinch today!
[...] http://askwpgirl.com/how-do-i-move-wordpress-from-a-subdirectory-to-the-root-directory/ Por admin el 26 agosto, 2012 / CSS, Diseño Web / 1 comentario [...]
I was wondering if you could help me. I have uploaded my wordpress page to my server but all the content in my site are gone. I have some of the links on my screen but they stand in the left side on the screen on top of each other and they are not supposed to do that and i’m missing my background and all of my pictures and the rest of my links can somebody please help me
You’re the BEST! Been tweaking dns, forwarding, masking, etc. Just tried your fix & :02 later, I was back in business. Thank you, thank you, thank you!
Worked Awesome! Thanks!
I could kiss you!
Perfect! Thanks a lot!
wow awesome thank you that was so much easier and actually what I preferred then doing it the way WordPress documents suggest.
Yay! I’m glad it worked!
Thanks, this was too easy.
Totally worked! Thank you SO much!!!
Amazingly helpful- comprehensive and well-explained. Definitely going in my archive of important info to be used again…
Thank you very much. I know, I’m the 371st person to say thanks, but one can never have too much praise right? I do have one question. Someone at my web hosting company said she has seen things go wrong with this redirect process when people customize their sites. Since so many people do this, I’m guessing she was incorrect. Anyone know if her statement is true? I’m planning on creating a child theme and I surely don’t want any problems.
I do this a lot with sites. It’s just a nice practice to keep the directory structure clean. I haven’t seen any problems, except if I had internal hyperlinks to the subdirectory that need to now not include the subdirectory. Otherwise, all the images and other uploaded files will not change, because they still exist in the subdirectory.
You are great. I was glazing over all other info and then I found your blog. It worked like a charm! Thank you!
Hi there,
First off all thank you for your great article it was very helpful.
My site was http://www.bratty.eu/display/ and I moved it in http://www.bratti.eu/ (root)
My problem is that after all the work (went extremely well) I searched in Google a page from my site, It found the page with the old url and when I tried to enter I had an empty page.
How can I fix that?
Thank you in advance
If you had the privacy settings turned off (ie allowed Google to search the site in the subdirectory), then there will be old URLs cached by Google. This will resolve itself in a few weeks, but here are some things you can do:
1 – Install the Redirection plugin and set up redirects on those pages to the new pages
2 – Install the Google XML Sitemaps plugin which will submit your sitemap to Google and help Google crawl your site easier.
Hi AskWpGirl!
I have a tricky question. I followed your nice instructions and wordpress is now in a subfolder and .htaccess and index.php in root. Everything worked fine for a year. Then I wanted to use a plugin called Boxer Pro. Boxer pro generates a short code that will show the content of several nice boxes on a page. The problem is that the code is only working if I type the whole address to the subfolder. Asked the company that delivered the plugin and they asked me why a used a subfolder… Do you know any way of solving this problem? Should i change my .htaccess?
Don’t change your .htaccess! That is not the problem. I don’t know how Boxer Pro works, but essentially, WordPress is installed in the subdirectory as are all your uploaded files, including images. So, in some cases, as with linked uploads, the URL with the subdirectory is needed. What we’ve done in my post is had all the page, category, and post URLs for the site (the site’s permalinks) use the root directory, but we did not move the WordPress application nor move the wp-content folder.
I don’t know what you are trying to do specifically with Boxer Pro for which you are referencing the subdirectory, so it’s hard for me to tell if this is a “problem” or just the way it should work given the location of the wp-content folder inside the subdirectory.
Hi Angela!
Many thanks for your reply:) I think I’m loosing my hair on this one;)
I forgot to mention you that since I moved the htacess and index.php files to the
root I can’t preview my pages correctly. I have to put in the subfolder name to preview
the page. Update page works fine though..
Thank you for the great article… I’ve encountered a 50/50 success result of your steps and hoping you can help lead me in the right direction…. After following your steps, all the urls/links for any subpage of my site work perfectly. However, the homepage still tries to point to the subdirectory, and I get a page not found error – just this one page.
any thoughts?
Thanks in advance.
Hi, I think the problem may be that your menu item under Appearance > Menus for the Home page is still the old URL with the subdirectory in it. Check that. If you just go to your site – the main URL – does the home page show okay?
If I go to the base domain, it automatically appends the sub directory path to the url, and displays a PNF. I don’t see anything in the menu section that specifies an old path.
Thanks for your feedback
works, many thanks
Hope you can help Angela. I did as instructed, and everything is working and displaying right, EXCEPT when the contact form is submitted, the Thank You message is being displayed on a blank page (instead of in a dialog box on the site). The form contents are being sent and received properly. Here is the web address of the page containing the Thank You message: http://amgcatering.com/amgcms/wp-admin/admin-ajax.php?action=sendmsg_submit
The site is using the Blocked theme, which is no longer supported by the developer. It doesn’t have any form plugins installed, so not sure what to do next. Thanks!
I just read over this and still debating whether I can tackle it. I need to update my site completely and the new one is done, I just worry about re-directs from Google. What will happen when someone stumbles onto an old page and it’s not there?
Hi Angela,
I have a new version of wordpress. Can you tell me how you replace this to make it works?
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
require_once( dirname(__FILE__) . '/wp-load.php' );
wp();
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
Thank you very much! It worked!! I’m having a problem now… I have another installation of WP in another directory and I cannot access the admin page. Any clue why could be that?
great guide, worked like a breeze. thanks very much!!
You have no idea how much time this saved me. Thank you for backstopping those Codex guys — I knew there had to be an easier way! Do you have a similar article for how to move (easily) from MAMP to a live host? That’s always a killer for me, and I know it forces a lot of people to develop ‘commando’ rather than deal with it.
One thing I didnt see mentioned in the thread was to double-check plug-ins that use internal absolute links, in my case, there’s a social media plug-in that hard links to the blog within the same subdirectory. Easy enough to fix.
Thanks for the feedback, Aaron. I really hate plugins and themes that don’t use the correct relative links. That’s just a sign of poor development.
Worked great for me — thanks! I did have to go through the extra steps, including editing the .htaccess file, and I needed to upload that to the root directory as well.
Thank you *so* much for these clear instructions. I followed them, and they seem to be working. Moved my site and all is well so far!
Thanks for the article. I have an issue with a site that has existed for a number of weeks. I have completed the instructions and all works fine the site when you navigate it is no longer showing the subdirectory.
However there are probably quite a lot of links from other sites which include the subdirectory in the URLs. I’ve noticed that on any parent level pages if you include the subdirectory in the URL it successfully redirects to the URL without the subdirectory, but any child menu pages with which you use the old site directory (i.e ‘domain.co.uk/site/parentpage/childpage/’) do not get redirected to ‘domain.co.uk/parentpage/childpage’.
So the first question, is there something I have done wrong or is this normal?
I’ve tried a RedirectMatch 301 but the redirect does not seem to be working, when I manually input a URL with the old Subdirectory it does not redirect to a version without it. Is my htaccess file correct (see below).
And surely if I use a redirect match like that it would it close access to the admin pages/login?
My htaccess file looks like the below at the moment (my wordpress install is in ‘subdirectory’) and I can successfully bring up the site and navigate pages without any problems at the root url:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RedirectMatch 301 ^/subdirectory/$ http://domain.co.uk/
# END WordPress
Any help would be greatly appreciated.
I think I may have answered my problem here with a bit of experimentation.
I had permalinks set to ‘post name’ when I was getting this issue. However I couldn’t understand why I was having the same issue on another site I administer.
Comparing all the settings I realised I had permalinks set to Day & Name for this other site.
I adjusted the permalinks to match on the site I was having problems with, and any external links to a page on the site with a URL incl;uding the old subdirectory will automatically be redirected to the correct permalink page/post URL without the subdirectory.
So far everything seems to work as expected.
Excellent. Thanks for sharing.
You have to be careful with wild card redirects like this because your wp-admin and the wp-content folder are still located in the subdirectory, so I wouldn’t use that type of redirect. Instead, you can install the Redirection plugin and manually enter redirects for the old page URLs to the new page URLs. My instructions work very well for development sites. It’s a bit trickier to do this process for older sites because of potential external links.
The reasons the posts redirect fine is because WP can generally parse that URL and figure out how to match the post title in the new location. Pages don’t work like that because of the page hierarchy — child pages. Changing a parent page URL will always result in broken links. Therefore, using the Redirection plugin for these specific pages is best.
Hi Angela,
Thanks for the article for moving the WP site to root.
I’ve used it alot and like Jaime, i realised that it seems to work only on the root level and the rest of pages/posts are still pointing to the development folder.
Is using the Redirection plugin the best way to “tidy up” the urls to point to the root level?
Daniel
When using this method, ALL of the posts and pages will display from the root URL. The only things that continue to “point” to the subdirectory are the WordPress dashboard (because the files for the dashboard are in the subdirectory, of course, sense we didn’t move WP) and the uploaded files (images and PDFs).
Thank you for this info. I am doing a whole revamp of my website, and have more than one install of WP and some subdomains and parked domains – the main part of my site is currently HTML. I plan add a new WP install for my main part (root), and am glad to see I can run it from a subdirectory while still appearing as root (while also running other installs of WP on the site.)
Can I have no other pages in the root that can be accessed once I virtually “move” the WP into root – or does every file need to be switched to a WP post/page? Does *everything* need to be in a subdirectory – or just pages and images? (There are other files in there, such as php redirects.) I have a contact POST form – can that be put into a WP post? Do these need to be put in a subdirectory?) I was planning to use redirect code on the old HTML pages to go to their new WP pages? Is that what the Redirection plug in is for? With Redirection do I need to enter the old page URL and the new post URL for every page that I switched from HTML page to WP post – doing essentially the thing I thought I was going to do – only through a plugin? Also it says Redirection hasn’t been updated in a while and isn’t confirmed to work with latest WP, does it?
Further on Redirection, on a current WP install. I want to change the permalinks (to take out date and just use post name.) I tried and WP did not redirect the posts. With Redirection, if I activate it before I change the permalink structure, will it automatically redirect them? Also I plan to change the subdirectory name that the WP install is in. I used Velvet Blues to update links for another WP install that I changed the name of, but it was much smaller and I wasn’t worried about redirects so much since navigation is much clearer. Do I need to use Redirection instead for this too, or will Velvet Blues work?
Thank you for all your info and help!
You can have other WP installs in subdirectories as well as subdomains. I have that on my site. For example, askwpgirl.com is in a subdirectory with the index.php file for it in the root, then I have a site installed in another subdirectory, which I access via that subdirectory and another subdomain in the a folder in the root directory. It all works fine. The only issue you could run into is if the subdirectory name matched the slug name (page or post or category url) of the main site.
You should delete the old HTML files and use the Redirection plugin to redirect to the new URLs. Also, install the XML Sitemap plugin, so that will give the Google Bots a new sitemap to crawl. You definitely want to use the Redirection plugin.
For the contact POST form, don’t use that! It’s a pain in the ass, and the Visual Editor in WP will kill the code. Instead, use a good form plugin to create a new form using WordPress, such as Contact Form 7, Gravity Forms (http://askwpgirl.com/go/gravityforms.php), or Fast Secure Contact Form. All except Gravity Forms which is a premium plugin are available from WordPress.org and can be installed via the plugins interface in the WP dashboard.
If you had previously used the date and then change to the Post Name format for the permalinks, you will need to use the Redirection plugin to make that happen. I’m not sure it will automatically pick up on that change, though.
If you change the subdirectory name, you are in a world of hurt. Everything will break or can break. You can do it, but you’ll need to use the Search and Replace plugin to do a global search and replace, but ONLY on the content. Some other plugin things might get screwed up to. In that case, I usually use BackupBuddy plugin (http://askwpgirl.com/go/backupbuddy.php) which you can do a “migration” to the new subdirectory and it will automatically rewrite all the URLs for you. No, do NOT use Velvet blues or Redirection plugin for this. That will result in weird, unnecessary redirection loops.
Sorry it took so long to respond. I was on vacation when you wrote. Feel free to email me if you have any more questions.
Angela
Hi AskWPGirl, thank you so much for taking the time to write all this up so clearly for everyone. I created a wordpress site in a “wordpress” subdirectory (www.collegecalm.com/wordpress) and was trying to change the Home URL to the main root directory. After some trial and error, I now have the site showing up at http://www.collegecalm.com but none of the images are showing up on any of the sub-pages. I did check the permalinks and saw that they were updated in the dashboard. Also, I have found that I cannot access the site admin dashboard unless I delete the web.config file in the root directory (I guess I do not have an htaccess file but this web.config instead??). When I do delete it, I can access the admin dashboard but the site no longer displays at all at http://www.collegecalm.com. I’m hosted on GoDaddy. You mentioned an issue with them updating once an hour. Do you think this could be the issue or is there a bigger problem? thanks, Sara
Just a followup from my post last night. After some further research, it looks like I should be using Linux so I’ve changed this in GoDaddy. After the change, I’ll see if I can get everything working properly.
Let me know how it went with the change to Linux. Windows hosting does mess up all the URLs pretty badly and is not recommended.
It solved everything. And the site runs much faster now!
Did you move it to the root?
Nope. Left it in the sub-directory and just used the WordPress console to modify the URL of the site while still pointing at the WordPress subdirectory.
thank you! this is exactly what I was looking to do. One problem I am seeing, if my old site was bookmarked, and you navigate to mysite.com/wordpress, it shows the “This is somewhat embarrassing, isn’t it?” error message. i tried a redirect from my control panel, but that does not work either. i tried to redirect mysite.com/wordpress to mysite.com, but it still shows the “This is somewhat embarrassing, isn’t it?” error message. any suggestions? thanks again!
Hi Jimmy,
I would recommend you install the Redirection plugin and enter 301 redirects from the old pages/posts to the new URLs.
Angela
Angela, before I proceed with your tutorial, can I get a confirmation that this is something that will solve my situation?
Lets say for example my site is BIKE.COM. This is the main wordpress site. Its 4 main folders: cig_bin, wp-contents, wp-admin, wp-includes are in the public_html folder.
I created a sub-domain called Shop.Bike.com. This wordpress site is also in the public_html but its 4 main folders are inside a folder called SHOP. Is the SHOP folder what you call a sub-directory?
So knowing my current set-up, should I still follow your instructions? Because I was immediately lost with step 1. LOL! It says to install wordpress, but don’t install it in the root public_html, install it in a sub-directory. Which had me confused immediately because I’m trying to move my sub-directory site into my main site, so why would I do that? I know there is probably some basic understanding that’s flying over my head right now.
Subdomain is not same as subdirectory install even though the subdomain is installed in a subdirectory. Therefore, my instructions will not work. You would need to follow the instructions here to “migrate” the site to the root public_html directory:
http://codex.wordpress.org/Moving_WordPress
This was a GREAT help — however, I have one big problem that could be entirely my own doing.
I’ve changed everything as suggested, and my blog that was previously under http://website.com/renewal is now appearing pristine on http://website.com — great!
However, I have a completely unrelated subdirectory under my root called ‘slide’, and while the index page of http://website.com/slide will display fine, anything UNDER the slide directory (like http://website.com/slide/reader/read/chapter_1/en/0/1/page/1) WordPress interprets as some complicated page name and tries to display using WordPress–which of course isn’t going to work!
If I change the permalink structure to the default (ugly /?page_id=##), the problem is solved, but then I’m left with ugly permalinks and faulty links all over the place since I’ve been using structure using the post/page title everywhere up til now.
Any suggestions at all? I’m desperate!
Hi Courtney,
I have had other HTML files in subdirectories and have never had this problem except when there is a similarly named page in the WordPress installation causing WordPress to try to interpret that URL as a post or page. WordPress will try to parse any URL that it sees to see if it is a WordPress page or post or category or archive, etc. I think it’s important that your naming conventions are strictly followed or WP will choke. For example, if you use capital letters in your directory names on the server, then the browser may not interpret the URL correct and WP will try to find the page and not be able to find it. If you want, you can email me via my contact form, and I’d be happy to poke around your FTP structure to see if there is something obvious that could cause the URL to not be read. It’s often something simple.
It turned out the htaccess file in the subdirectory itself required a bit more finessing (ultimately, after a harrowing few hours, I finally realized the one line missing and resolved the issue).
I’m now having issues with the permalink structure mucking up my bbpress installation, which suggests that I and my good friend .htaccess will be spending a bit more time together, but at least this has been resolved.
Here’s what I think is happening: You have too many .htaccess files. I would personally delete ALL of them (or rename them .htaccess-bk). Then, login to WP, and go to Settings > Permalinks and click Save Changes. This will automatically generate a correct WP .htaccess file for WP which then should not mess up your subdirectory with the static HTML files. I have encountered similar issues when people have had a bunch of .htaccess files all over the place. Having just the one with the proper WP settings as auto generated with the settings page will typically take care of these problems.
Alas–an excellent suggestion, but ultimately a futile one. WP generated a lovely new htaccess file just fine, but bbpress remains intractable. For a plugin developed by the wordpress creators themselves, it sure does have a lot of difficulty properly integrating with wordpress :/ It appears I’m going to have to try a commercial solution, as the bbpress support forums have never been much help…
Some more complicated functionality might not respond well to operating in a subdirectory. I know BuddyPress has a hard time if doing this method of installing in subdirectory and running from the root. What you might want to consider doing is using a plugin like BackupBuddy to backup the entire site (db and files) and “migrate” it to the root. Using Backupbuddy will help with all the URLs that need to be rewritten in the database when “moving” WordPress without breaking anything. You can also just physically “move” WordPress to the root and change the General Settings accordingly, but then, you would have to do some SQL query to rewrite the URLs from the old to the new. There are numerous blog posts on how to do that without messing things up, but I find BackupBuddy to be the most fail safe method. It’s possible, then, that bbPress will be happier running from the root rather than redirected to the root.
I have never run bbpress out of a subirectory situation like this. Also, be sure it’s bbpress and not the custom menu item that needs to be fixed. However, it wouldn’t surprise me if being in the subdirectory but redirected to the root for the URLs could have confused it.
“Also, be sure it’s bbpress and not the custom menu item that needs to be fixed.”
I can be quite sure it’s not the menu item, as even links such as the latest post in the freshness column or links to individual replies in a topic thread itself throw the same error. It’s very much that URL itself that’s proving problematic.
I had actually originally intended to do just that–move the wordpress installation to the root and run it from there–but after seeing how complicated it would be and all of the database adjustments I’d had to take, I was relieved to find this alternative which seemed so simple.
Do you know of any good hand-holding tutorials for using backupbuddy off the top of your head, or shall I do some googling now? I haven’t come across that option thus far, and it seems like the path of least resistance.
Hi Angela,
Thanks for your instructions. I have followed them, as well as the official codex instructions, and keep ending up with a blank root homepage. Any ideas?
Ah! I wonder what might be happening. Can you contact me via my contact form with the URL to your site? It does sound like perhaps a little mistake.
Hi Angela,
I wanted to follow up on the record and say that migrating my site from a Windows account to a Unix account resolved all the of issues I had been experiencing. Your instructions took me all of 90 seconds just now to get a working site. Thanks for pointing me in the right direction!
Hi
I was VERY excited to find this post and followed your instructions to the letter but can’t get the menu items working. The site redirects properly but when I remove the “staging” part of the URL from the menu items the menu goes to the root directory – where there is nothing there. You mention a possible fix in the header.php file but you don’t say what that is. Is it in here?
Thanks
Charles
Hmmm… the wp_get_nav_menu should just get the URLs for the pages, which, if you followed the instructions, should now use the root URL not the subdirectory. Have you created a custom menu under Appearance > Menus or are you using the default menu of pages?
Can you visit a page okay without the subdirectory in the URL (not using the navigation)?
You can contact me via my contact form with your URL if you want me to take a peak.
Thanks for your SPEEDY reply Angela, this is awesome! I need to make this live ASAP! Yes, I’ve used Appearance > Menus – 2 of them are custom and the others are just a Page but I could make them custom. I can’t remember if I removed the index.php file from staging when I tried this earlier today though. I don’t mind giving you access, but how do I do it without posting login info here?
Charles
OK I have everything redirected including a “silence is golden” index file in the staging folder. Here’s the site I’m working on. http://cowanandcompany.ca/ As you can see nav links go to the correct URL but don’t resolve to the right page. WP is setup in http://staging.cowanandcompany.ca/
Hmm what seems odd is the permalink thing – you have your path blacked out so it’s difficult to tell how it works – but the original permalink where my wp is installed was:
staging.cowandcompany.ca
- now if I make your change for example “contact” would look for this -
cowanandcompany.ca/staging/contact/
which isn’t correct so I can see why it comes up blank – even if I use dot…
cowanandcompany.ca.staging/contact/
it’s in the wrong order.
Sorry, I think I see my problem. You have SubDIRECTORY not subDOMAIN as the path. I guess this won’t work for subdomain.
Interestingly, I was in a panic and didn’t have time to call the service provider and have them start changing the staging site’s DNS – so I took a crazy chance and just re-uploaded the entire staging site (wordpress installation and all) to the root directory (there was nothing there previously). Then I logged into the Dashboard and changed both addresses to the root level and it worked! Some of the images are still pointing to the old staging area uploads but that’s OK. This service provider doesn’t locate the database where the domain is so it still was able to connect to it without changing the config.php file. Just an FYI for anyone else who runs into this brick wall at 7pm when the site has to be live ASAP!!
On to a new installation this time I’m going for a subFOLDER and I will be trying this method out. It’s a lifesaver! I wish I had seen your article in 2011. I searched the web for this topic a few years ago but couldn’t find a good solution – only some scary looking plugins that “might work”.
Thanks for figuring this out and for your speedy response!
Charles
Yes, the config file should not have to change if you stay on the same host. If people decide to actually physically move the WP installation to the root, instead of following the method outlined in this post, they would want to first change the General Settings to remove the / and the subdirectory name (important that site does not end with trailing /), then move all the files to the root (aka public_html folder), then use the Search and Replace plugin to rewrite the URLs to the images and hyperlinks (important to ONLY do Search and Replace on CONTENT area, otherwise, there can be unexpected consequences doing a full search and replace in the database — such as republishing of all your posts to the RSS feed).
For “moving” WordPress or doing other types of migrations from one site to another, particularly if the site URL changes (from a dev server to a live server), I usually use the BackupBuddy plugin, because it automatically handles all the URL rewrites correctly, with the exception of some plugins I’ve used for sliders that might have the image URL stored in a way that BackupBuddy does not typically access.
Anyway, glad this whole process worked out for you.
this was perfect! so helpful. thank you for this post. going to bookmark it for later use. =)
Thank you so much for these clear and concise instructions. I read the ones on the official WordPress site first, but found them a bit confusing as they seem to implicate a 14 step process may (or may not–HAH!) be necessary. Yours are much better and took literally 60 seconds to implement! They also saved me tons of time, as I was considering trying to migrate my site from an old Drupal install to a new WP one–eeeek. Knowing I could develop the new site fresh in a WP subdirectory and “move” it instantly to root made my life 10,000 times easier, since doing anything remotely complicated with Drupal is a triple nightmare.
A note: I’m on Hostgator and didn’t need to copy/move .htaccess. I deleted the old .htaccess file in root that contained the Drupal settings, and it spontaneously regenerated.
Thanks again!
I’m doing just this for a client and am overjoyed that someone was great enough to break it down. I’ve not done this yet and this looks like it will make the job a whole lot easier. Thanks so much, Angela!
That’s awesome, Maxwell. Good luck!
Hi Angela hoping you can help me. I have a site set up for my son who is in the NICU to keep my family up to date with his progress. I changed the WP URL which caused the site to break. I fixed it eventually by editing the config file but my theme looks like it’s not working anymore. The theme is showing installed still but the HTML/CSS is gone from the site. I am wondering if I need to edit another file to fix this…. can you assist? It is the contango theme and all the theme files are showing in my hosting folder including the css…. I saw something out there about editing the style.php to fix but cannot find that file…. Thanks for your help!
Hi Jen,
Yes, contact me via my contact page, and I can probably help you quickly.
Hi Everybody,
I have successfully migrated from olddomain.com/wordpress to newdomain.com. It is actually stored under newdomain.com/wordpress but I have made this “transparent”,
All works fine till now… crossing fingers
)
My only concern are google webmaster tools… only available for root domains. So I cannot transfer my olddomain.com/wordpress links to newdomain.com.
Anyone has got the same problem and has managed to fix it?
Thank you in advance for your help!
If you are changing domain names, there are two things you can do:
1 – Add both the old and new domains to Google Webmaster Tools. You will have to download and FTP the unique html verification file to both the accounts. Then, you can indicate in the Webmaster Tools for the old account that you have changed the address. This is just a nice informational thing to do for Google.
2 – If you had a lot of traffic on the old domain, then you can install an .htaccess file on the old domain with this code to do a wild-card redirect to the new domain. It will automatically redirect all all the old URLs to the new URLs:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain.com/wordpress$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com/wordpress$
RewriteRule ^(.*)$ http:/newdomain.com/$1 [R=301]
Do not use this rewrite to redirect mydomain.com/wordpress to mydomain.com as that will mess up your access to the WP admin directory if you still have WP installed in the subdirectory.
If you did have a site at mydomain.com/wordpress which had a lot of traffic for which you just decided to display at mydomain.com, then you can use the Redirection plugin to redirect the old URLs to the new ones that do not contain the /wordpress.
Just thought I’d toss in something that was helpful for me. While following these directions worked for my homepage, all subpages would return a HTTP Error 500 (Internal Server Error). No matter how much futzing with the .htaccess file and/or the index.php file I did, nothing seemed to work. On a whim, I deactivated *all* plugins and: voila! All subpages began working. I then turned each plugin back on, and all of them seem to work fine now. The one problem I’m still having is that I can no longer seem to preview changes to pages, instead it returns, “You do not have permission to preview drafts.” This is a bummer, but at least everything else is up and running.
Hi Travis,
Thanks for writing. Yes, that is very puzzling. Sounds like a badly coded plugin. I have never had an issue with plugins with this process. However, one thing you can do is DELETE your cookies in your browser and delete your browser cache. That should solve your preview issues. It could be the authentication for your user session vis a vis the browser cookie got confused.
Let me know!
Angela
Hi
I am just about to start implementing the switch over and have just one question. My current site which is in the root directory has an index.html file and then numerous html files for the various pages.
I am wanting to do 301 redirects for all html pages to my new wp pages to keep my link juice.If I have to remove the index.html from the root then won’t the 301 for this page be useless?
Any help would be great and I really appreciate your excellent advice.
Regards
Robert
Hi Robert,
When you are ready to make the switch, copy all of your old HTML files into a folder, so they are no longer in the root. Later, you can download these as an archive and then delete them on the server. The reason I say to put them in a folder is just in case you need them immediately, but you definitely want to not have any of them in the root, particularly the index.html file.
You do NOT need any of these pages existing to do the 301 redirects, and it’s better if they are deleted ultimately.
After yo do the process outlined in this post to move your WordPress index.php to the root and make the other changes per the steps in this post, then you can install the Redirection plugin and do 301 redirects on all those old HTML pages to your new WordPress pages. Again, those old html pages can be deleted and do not need to exist in order to redirect their URLs to the new URLs. However, you will want to make note of all those old URLs in order to do the redirects correctly.
Good luck! Let me know how it goes.
Angela
Thanks Angela. it worked a treat. I am now going to devour your whole site for useful information
Thanks again
Hi Robert,
That’s awesome! I will try to post more things soon! I have two dozen posts in draft mode
Angela
Hello Angela,
Since a while I redirected all the ancient static pages on my painter’s website to my WordPress installation which I formerly used as a blog. And now I wish to cancel the /blog/ from my Url to keep only the root (hazlotopics.com). But I could never achieve (hopefully I’ve been able to switch back to the previous state and my site works again). So I’d like to precise a couple of things with you if you are ok.
1/ In the WP codex I found this sentence: “The “Home” setting is the address you want people to type in their browser to reach your WordPress blog”. But in another page of the WP codex (Using a pre-existing subdirectory install) : “In the box for Site address (URL): change the address to the root directory’s URL”.
So it looks like I did it wrong when changing the first field (Home) to the root directory. I should have change the second one named Site Url. Do you confirm?
2/ After I did it, I could not login anymore, my site turned upside down, and the WP Settings page changed into a warning page wherein it was written:
Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/XXX:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/XXX/public_html/blog/wp-admin/includes/misc.php on line 133
Warning: Cannot modify header information – headers already sent by (output started at /home/XXX/public_html/blog/wp-admin/includes/misc.php:133) in /home/XXX/public_html/blog/wp-includes/pluggable.php on line 876
The first warning mentions php4 but when I checked my htaccess I could never find something like the sentence “AddHandler application/x-httpd-php5s .php” (found in your other post) even though my web hosting runs with php5.
3/ And finally, in case I can fix it and change my Url to the root, I’m not really sure of how to set the plugin “Redirection” in order to redirect all my actual /blog/ Urls all at once (and same for my old static pages which have all been redirected one after the other with the redirection tool of the cPanel).
Hope my questions are not too confuse.. Hope my english is Ok too!
Thanks in advance.
From France, kind regards.
Hazló
Hi Hazio,
1 – The process I describe in my post are instructions for successfully keeping the WordPress installation in the subdirectory while display all post and page URLs from the root.
2 – It’s important to not have any typos or forward slashes in the URLs. Not sure if your problem is related to that or the .htaccess file. You can contact your web host to ask them how they are handling the PHP 5 selection. Some do it via .htaccess, others do not. If you did not edit the index.php file and move it to the root, then there can be problems with WordPress finding the installation. Or, your theme could be poorly coded and not finding things correctly. If something was not set correctly, you can login to your web hosting control panel and access the WordPress database via phpMyAdmin and reset the settings. Please see this post on how to do that:
http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/
3 – It’s hard to do bulk redirection simply because ALL of the image URLs, uploaded files, and WordPress application itself will still be located in the subdirectory. In this case, it might be better to actually physically MOVE the WordPress installation and then you can use an .htaccess redirect to do a bulk redirect to the root, but you’d also need to run the Search and Replace plugin on the content of the site to replace any image urls, uploaded file urls, and internal links to the new url without the blog in the url.
For the old site HTML files, the bulk .htaccess redirect (see below) will simply redirect the exact same name URLs not the old htmls, so you will need to re-enter the new location for those in the Redirection plugin (though since those redirects are already in place, the .htaccess file may take care of the redirecting them yet again).
Here’s the .htaccess bulk URL redirect command:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydoman.com/blog$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com/blog$
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301]
Again, this ONLY works IF WordPress is MOVED to the main directory and is NOT in the subdirectory. But, first, take care of what was messed up on the current site, so you know everything works before you attempt to move anything in the FTP folders. Let me know if you need some help.
Thanks a lot Angela for taking time to answer to the questions of a “rookie”. I’ll check the php situation with my web host.
Concerning the htaccess, I thought I could maybe first replace the main directory current one (which I saved) with the one of the wordpress subdirectory and then copy inside it the current redirections (old static files).
And of course I’ll try to use your bulk url redirect command for the current /blog/ Urls.
Does this make sense for you?
It seems to me easier than to physically move the WP installation because I’m a bit scared with the searchandreplace scripts or plugins (I’m not that aware of how to set them good and they can easily break all).
Thanks again for your patience!
Everything is fine now after I carefully followed your instructions.
Concerning my ancient static files,I finally found a way to redirect all the folder to the actual site, with the following code in the main htaccess (excluding some pages that I prefered to redirect to a specific url) :
RedirectMatch permanent ^/AncientFolder/(?!SpecificPage.html)(.*)$ http://www.domain.com/index.php
So Google should be happy!
Thanks again Angela for your helpful reply, for the posts here, and for the time you spend for the others.
All the Best!
Worked Great and saved me tons of time. Thank you very much!!
Sweet!
Hi Angela, Thank you so much for this post!! I have bookmarked this page and others, because they have been so helpful. When my site is up, I will definitely provide you with some link juice.
Just one question, but will the steps above work if I am using a Genesis and StudioPress theme? I have just completed a WordPress sub-directory install (for all the reasons mentioned above) only to be told it might not be possible to copy or move my website over to the root? Would you be able to shed any light on this? or Should I just start fresh and do a root directory install.
The reason perhaps they told you it would not be possible to copy or move the website to the root is because it is cumbersome to actually “move” the installation to the root and will break a lot of stuff — like all your image links. This is why the process outlined in this post is awesome, because you don’t “move” WordPress — you just tell WordPress what URL you want to display the permlinks from and what URL the WordPress application is actually installed under. Simple. Clean. Easy.
Awesome Information on this page. I tried a number of combinations to try to get this to work properly. I have done this before in wordpress and it was a piece of cake, but it must have been the hosting company I was using (HostGator). Today my client is using Godaddy as the host.
I followed all of these steps to a T, but was unable to get it to work. What I ended up having to do is copy .htaccess and index.php file from the subdirectory to the root. I deleted the original .htaccess and followed your steps on having WP create a new file. When I tried http://www.domain.com without the subdirectory, I was getting “Warning: require(./wordpress/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home/content/31/8187731/html/wp/index.php on line 17″
This told me something was up with how this file was being referenced. So I changed the code in the root level index.php file
From:
require(‘./wp-blog-header.php’);
To:
require(‘WordPress/wp-blog-header.php’);
I also had to make some changes to the .htaccess file.
The home page loaded fine but none of the other blog pages would load. I then went into the /Wordpress/index.php file and removed the step were I added and replaced it with the original code.
I have spent way to much time to try to figure out if there is a better way of doing this. Your feedback would be great Angela and I wish I found this article last night. Thanks again for this post.
Hi Tom,
Please reread the step-by-step instructions on:
http://askwpgirl.com/how-do-i-move-wordpress-from-a-subdirectory-to-the-root-directory/
Read step #4. You did not edit the index.php file correctly. Look your code in the index.php file correctly. The correct syntax should be:
require('./WordPress/wp-blog-header.php');Editing the index.php file correctly should fix the problem. Let me know.
Angela
The point that I am trying to make is that
require(‘./WordPress/wp-blog-header.php’);
Does NOT work.
require(‘WordPress/wp-blog-header.php’);
Works
The issue here I think is the relative URI . I did not try to this but I would bet /Wordpress/wp-blog-header.php.
Hi Angela,
Just did this properly on a new site with a subFOLDER! BRILLIANT!!!! You are a miracle worker – thanks so much – from now on I’ll be using this on every WP site I build.
Charles