Title: Moving WordPress from a Subdirectory
Last modified: August 30, 2016

---

# Moving WordPress from a Subdirectory

 *  [elvis99](https://wordpress.org/support/users/elvis99/)
 * (@elvis99)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/)
 * I have setup a new wordpress site in a subdirectory of my site.
    Ex. [http://www.mysite.com/wordpress](http://www.mysite.com/wordpress)
 * I have the new site ready and want to move it to the root directory so that /
   wordpress does not show in the url.
 * Do I just copy all of the files in the wordpress directory to the root or is 
   there an easier way to do this?

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [SJW](https://wordpress.org/support/users/whitsey/)
 * (@whitsey)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319593)
 * The easiest way is as follows:
 * TELL APACHE WHERE WORDPRESS IS
    WordPress address (URL): [http://example.com/wordpress](http://example.com/wordpress)
   Website address (URL): [http://example.com](http://example.com) 1. Copy the index.
   php and .htaccess files from the /wordpress directory into the root / directory
   of your site (Website address) 2. Edit /index.php and change the line that says:
   require(‘./wp-blog-header.php’); to: require(‘./wordpress/wp-blog-header.php’);
   3. Login to /wp-admin and update permalinks and save
 * [https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install](https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install)
 *  [leejosepho](https://wordpress.org/support/users/leejosepho/)
 * (@leejosepho)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319600)
 * > Do I just copy all of the files in the wordpress directory to the root
 * No. You can do that, if you wish, but you would first re-save Settings > General
   for the new URL. The very simplest thing to do, however is to leave all of that
   alone and just redirect your domain to WordPress right where it is:
 *     ```
       # BlueHost.com
       # .htaccess main domain to subdirectory redirect
       # Do not change this line.
       RewriteEngine on
       # Change example.com to be your main domain.
       RewriteCond %{HTTP_HOST} ^(www.)?example.com$
       # Change 'subdirectory' to be the directory you will use for your main domain.
       RewriteCond %{REQUEST_URI} !^/subdirectory/
       # Don't change the following two lines.
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       # Change 'subdirectory' to be the directory you will use for your main domain.
       RewriteRule ^(.*)$ /subdirectory/$1
       # Change example.com to be your main domain again.
       # Change 'subdirectory' to be the directory you will use for your main domain
       # followed by / then the main file for your site, index.php, index.html, etc.
       RewriteCond %{HTTP_HOST} ^(www.)?example.com$
       # use index.php for WordPress
       #RewriteRule ^(/)?$ subdirectory/index.html [L]
       RewriteRule ^(/)?$ subdirectory/index.php [L]
       ```
   
 *  [SJW](https://wordpress.org/support/users/whitsey/)
 * (@whitsey)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319630)
 * Forgot to include – you need to update the site URL and home url in settings -
   > general before step 3
 *  Thread Starter [elvis99](https://wordpress.org/support/users/elvis99/)
 * (@elvis99)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319685)
 * Thanks for the replys. My site is hosted with Yahoo and there is no .htaccess
   file.
 * I changed the following settings in WordPress:
    WordPress address (URL): [http://example.com/wordpress](http://example.com/wordpress)
   Website address (URL): [http://example.com](http://example.com)
 * I then edited index.php and changed the line that says:
    require(‘./wp-blog-header.
   php’); to: require(‘./wordpress/wp-blog-header.php’);
 * Now the sites homepage loads but all of the links are broken.
    It just says “
   404 – Not Found”
 * Is there something else I need to do?
 *  [leejosepho](https://wordpress.org/support/users/leejosepho/)
 * (@leejosepho)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319687)
 * If you have access to phpMyAdmin, you can edit these lines to reflect your own
   table_prefix in place of ‘pref’ and to use your own old and new URLs, and then
   run those edited lines as SQL to search your database and replace all instances
   of the old URL with you new one:
 *     ```
       UPDATE pref_options SET option_value = replace(option_value, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
       UPDATE pref_posts SET guid = replace(guid, 'http://www.olddomain.com', 'http://www.newdomain.com');
       UPDATE pref_posts SET post_content = replace(post_content, 'http://www.olddomain.com', 'http://www.newdomain.com');
       ```
   
 * * note: Change above ‘pref’ (three places) to correct table_prefix and change
   old and new URLs (three places each and no trailing slashes)
 * If you do not have access to phpMyAdmin for editing your database directly, I
   believe there are plugins that can do that and run those same lines.
 *  Thread Starter [elvis99](https://wordpress.org/support/users/elvis99/)
 * (@elvis99)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319694)
 * I do have access to phpmyadmin but am not real familiar with it.
    I see that 
   all the table prefixes begin with wp_
 * Would I just run the following on the SQL tab?
 *     ```
       UPDATE wp_options SET option_value = replace(option_value, 'http://www.mysite.com/wordpress', 'http://www.mysite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
       UPDATE wp_posts SET guid = replace(guid, 'http://www.mysite.com/wordpress', 'http://www.mysite.com');
       UPDATE wp_posts SET post_content = replace(post_content, 'http://www.mysite.com/wordpress', 'http://www.mysite.com');
       ```
   
 * If I do this do I still need to make the changes mentioned above?
    Thanks!
 *  [leejosepho](https://wordpress.org/support/users/leejosepho/)
 * (@leejosepho)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319708)
 * You have the right idea, but I do not think ‘[http://www.mysite.com/&#8217](http://www.mysite.com/&#8217);
   is your actual URL. Also, it is never a good idea to post your table_prefix publicly…
   and neither is it all that great to have the default ‘wp_’ running anyway. So
   overall, I would first make an “export all tables” backup of your database, then
   run the SQL with the actual old and new URLs, then do another backup and then
   change your table_prefix…and there is more than one way to do that. Some plugins
   can do that from your Dashboard, and I use BulletProof Security for that since
   I already know it gets all the fine details exactly right.
 *  Thread Starter [elvis99](https://wordpress.org/support/users/elvis99/)
 * (@elvis99)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319719)
 * I just used mysite.com as an example. I would replace that with my actually domain.
   
   I will give it a shot. Thanks!
 *  Thread Starter [elvis99](https://wordpress.org/support/users/elvis99/)
 * (@elvis99)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319809)
 * I moved all of the wordpress files to the root directory and ran the updates 
   on the database.
    The homepage loads but all of the other pages still come up
   with 404 not found error. If I change the permalinks to the default settings 
   the pages do load correctly with the id’s but I cannot get the permalinks to 
   work right. Is there anything else that would cause this?
 *  [SJW](https://wordpress.org/support/users/whitsey/)
 * (@whitsey)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319820)
 * Doing that will fix the old issue but create a whole new world of new issues.
 * what are your site URL and home URL in Settings -> General
 *  Thread Starter [elvis99](https://wordpress.org/support/users/elvis99/)
 * (@elvis99)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319824)
 * They are both the same after moving the files into the root:
    WordPress address(
   URL): [http://example.com](http://example.com) Website address (URL): [http://example.com](http://example.com)
 * I spoke with Yahoo and they said WP must be installed in a subdirectory.
    They
   do not allow an .htaccess file so the subdirectory shows in the URL for all pages.
   Ex. [http://example.com/wordpress/contact](http://example.com/wordpress/contact)
 *  [leejosepho](https://wordpress.org/support/users/leejosepho/)
 * (@leejosepho)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319830)
 * > I spoke with Yahoo and they said WP must be installed in a subdirectory.
   > …the subdirectory shows in the URL for all pages.
 * Ask them specifically about assigning your domain to that sub-directory so that
   folder name does not have to be part of your domain URL to get there. At my own
   host, a primary domain *cannot* be assigned to a sub-directory such as your host
   requires, and I use that .htaccess so I *can* have it there anyway. Overall, 
   however, it is difficult for me to believe your host has things configured so
   that you *must* have that folder name in your URL.
 *  [SJW](https://wordpress.org/support/users/whitsey/)
 * (@whitsey)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319848)
 * What happens when you change the WordPress address (URL) to: [http://example.com/wordpress](http://example.com/wordpress)
 *  Thread Starter [elvis99](https://wordpress.org/support/users/elvis99/)
 * (@elvis99)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319853)
 * I ended up having to keep everything in a subdirectory in order for the site 
   to work.
    So I am back to the following settings: WordPress address (URL): [http://example.com/wordpress](http://example.com/wordpress)
   Website address (URL): [http://example.com/wordpress](http://example.com/wordpress)
 * I am just stuck with /wordpress in the url. Yahoo told me there is nothing they
   can do about this. I think the only solution is to switch hosts.
 *  [leejosepho](https://wordpress.org/support/users/leejosepho/)
 * (@leejosepho)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319854)
 * Somewhere I once saw something about making that *look* different in a browser
   address bar, but you have no .htaccess (as I recall) and that would not change
   the actual access URL anyway.
 * > I think the only solution is to switch hosts.
 * Possibly. Different hosts have different configurations where some assume/require
   specific assignment to a given “site builder” or whatever of their own.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Moving WordPress from a Subdirectory’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 15 replies
 * 3 participants
 * Last reply from: [leejosepho](https://wordpress.org/support/users/leejosepho/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/moving-wordpress-from-a-subdirectory/#post-6319854)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
