Many people like to create and test a new version of their site in a subfolder so that it does not affect their main domain. Once completed, they will want to migrate the new site over to the root directory for the domain. This is very common with WordPress. Follow the instructions below as we guide you on how to move WordPress from a Subfolder to the Root Directory.
Make a Backup of your account
Before performing the following procedure, it is a good idea to make a backup of your account prior to making any changes. Learn how to make a backup here: Backup website files in cPanel.
Prepare your WordPress installation for the move
Prior to physically moving the files, you will need to prepare the installation to accept the new URL name.
From the main dashboard, go to Administration -> Settings -> General.
Next, look for the WordPress address (URI): and change it from (example.com/WordPress to example.com)
Lastly, look for the Site Address address (URL): and change it from (example.com/WordPress to example.com)
Moving your WordPress from a subfolder to your main folder
After you have made your backup, removed the site files from the builder, and prepared your WordPress files, it is time to move your WordPress to the primary folder.
From the main cPanel area, look for the Files category and then click on the File Manager tool. Go to Settings In the Preferences window that appears, select the checkbox entitled Show Hidden Files.
Once inside the File Manager, you will want to navigate to the folder you have the WordPress site in. For example, a folder named WordPress.
You will see a list of all the WordPress files and folders in the right hand panel. Highlight them all and click on the Copy icon from the menu toolbar across the top of the page.
A popup will appear so you can enter the destination folder. Continuing with our WordPress folder example, it should show as public_html/WordPress. Remove the /WordPress from the destination path so that it simply displays as public_html. Click the Copy Files button.
This will copy the files up to the public_html folder. Use the File Manager to navigate back to the public_html folder. (You can do this by clicking on the Up One Level button from the toolbar across the top of the right hand panel.)
You should now see the same files as you have in your WordPress folder.
You can now delete the old WordPress folder.
Log in and finish the URL details
Log into your NEW WordPress admin dashboard. For example (example.com/wp-admin or example.com/wp-login.php)
Go to Administration -> Settings -> Permalinks and ensure the link structure is the same as your new URL.
Are you interested in unleashing the power of WordPress? Our managed platform for WordPress is fine-tuned to deliver superior performance, security, and provide best-in-class hosting. Be sure to check out our WordPress hosting plans.
124 thoughts on “How to Move WordPress from a Subfolder to the Root Directory”
I’m a student and gamer so recently I installeded wordpress at Takenbest Site but after sometimes, I need it to migrate to a sub domain but it showed database error, what should I do.
I can share its picture with error details but here no option to share photos.
Fantastic instructions
Thank you
I did have to install the “Search and Replace” plugin by InfoD74, to fix all of the image and link urls, which worked perfectly as well.
wordpress was setup in mysite.com/wp/
but I cant find Administration -> Settings -> General.
Next, look for the WordPress address (URI): and change it from (example.com/WordPress to example.com)
Lastly, look for the Site Address address (URL): and change it from (example.com/WordPress to example.com)
Hello and sorry for your issue. In the WordPress dashboard you’ll see Settings on the left. If you do not see this, you may not have admin rights within that WordPress website.
It’s Very usefull to me as I was looking for some tricks to transfer files to the root directory. Searched so many blogs but you guys are amazing on this job, and usally I don’t leave a comment but your article is so good and helpfull that I thought and writing this.
Again thanks for the simple trick, as I’m not going to use Duplicator plugin no more.
We would need more information to help you. Please provide details on the issue and we can try to help. You can also contact our live tech support team (contact info at the bottom of the page).
After i have update the wordpress and site URL, how can i go back and reverse it?
Also, i find something strange is that when i entered the URL, xxxx.com then it redirect to xxxx.com/subdirectory and i manually delete the subdirectory then it’s fine, is there anything or configuration in c-panel that i need to update?
You would need to change the settings again with the updated URL to revert it back. We do not block mobile traffic explicitly, so I’m not sure why your phone would not see the site. Can you describe what you’re doing on your phone that is different from the computer? Note that WP does have a default area in the .htaccess file. If changes are made there or re-direct changes are applied above their code OR if another .htaccess file has precedence over the one for your WP site, then it can affect the behavior of the website. Also, if you make changes to the .htaccess file of your WP site then you should always make sure to clear the browser cache before trying to re-load the site in that internet browser.
Ensure you have updated your “WordPress address (URL)” and “Site Address address (URL)” as described in the first section above. Also, test with another browser or clear your browser cache before testing.
I just wanted to let you know that I just did this and it worked beautifully!! Thank you – such a relief. The only hitches I had was links to some media files like pdf or video or audio files which I had to update. But overall, everything moved over like a dream. Thank you!
I recommend checking your .htaccess files stored on your server, as the error indicates that is the cause of the issue. However, since it does not specify the location of that file, you should check all the .htaccess files.
It sounds like you may have an under construction plugin enabled or an index.html file your browser is defaulting to in your document root, i would recommend disabling any underconstruction plugins and removing any excess index files.
2. Using WordPress toolkit, implement Move installation
3. Using the Duplicator Plugin reccomended by WP Beginner https://www.wpbeginner.com/wp-tutorials/how-to-properly-move-wordpress-to-a-new-domain-without-losing-seo/
i have migrate https to www in phpmyadmin(wp-option). But the images url still pointing to https. How can change that to www? Help me to solve this please. Thanks in advance.
Yes, I advise following our guide on correcting image links after migration, which covers how you can search and replace old URLs, updating them to the new string.
Hello! I have a main domain in my root folder and an addon domain (unrelated to the main domain) as a subfolder in the root. I made a dev subfolder in the addon domain, which is located as another subfolder in the root, alongside the addon itself. I want to move my dev subfolder to the root and delete the addon domain.
Do I need to take any extra steps in this situation? Will the files for the main domain interfere with the dev subfolder once I move it to the root?
Thanks for the question about moving the dev folder. As long as it’s in the folder, there should be no interference with the other files. You will need to make sure that you change the root location for the subdomain if you have defined it as a subdomain in the cPanel. If not, then you don’t have to worry about it. If you have configurations which rely on the location of the dev folder then you may need to change the location of the folder.
I hope this helps to answer your question, please let us know if you require any further assistance.
Thanks for the question about moving your dev folder. No extra steps are necessary. As long as the files remain in the folder then they shouldn’t interfere with anything else. Of course, there shouldn’t be a duplicate of the dev folder – otherwise, you’ll have a naming issue. If you have any configurations relying on the location of the dev folder then you will need to change the location to match where you have moved it.
I hope this helps to answer your question, please let us know if you require any further assistance.
Since my WordPress website is currently still under www.example.com/wordpress/, all the internal links also contain /wordpress/. After I have followed the steps in your tutorial, will all the internal links change to URL’s without /wordpress/?
If you have hard links in a post or page, then you would need to update them. However, anything new will NOT have the subdirectory included in the path. After you have made the change, make sure that you are updating the permalinks in your WordPress installation.
If you have any further questions or comments, please let us know.
I’m about to move my new WP website to the root and delete my current website, but I have a question. In my current .htaccess file I have a long list of redirects and this code:
Great tutorial – worked like a dream. I usually use Duplicator, which is free and also goo but this method is the easiest and fastest I;ve come across.
I completed all the steps. However if i goto my homepage www.xxx.com it still has my hosting providers page saying if you own this please upload to public_hmtl.
But if i goto www.xxx.com/aboutus that page will come up and so will the others, only the homepage wont?
The intro page may be index.htm or index.html and your first page is index.php. If that is the case, rename the index.htm or html page. This should allow the index.php page to show for your site.
Don’t know if this impacts anybody (perhaps a note in the installation directions) but when I did the conversion try as I might I couldn’t get the wordpress changes to appear.
It suddenly occurred to me that my existing site uses index.htm andthe wordpress uses index.php. After renaming my existing index.htm Firefox now brings up my wordpress site.
Hi , I’m haveing a problem i’m using the web.com cpanel and i can’t get the files to the root and even i tried installing the wordpress direct to the root but it want let me , I tryed even serching on youtube but on web.com nobody has a video ( and web.com support want help me ) so what shoud i do ? i even tried on filezila and it want let me in
Unfortunately, it is difficult to say since I do not know the access levels of their setup. I do know on our servers, you have access to your files via cPanel File Manager, or FTP.
Make sure to check if the Site and Home URL were updated after the move. You can add change this setting in the WordPress General Settings, as mentioned above in the section headed “Prepare your WordPress installation for the move”. You can also add set the Site and Home URL in the wp-config.php file to get the same effect.
could you please explain to me what this error is https://www.**********.com/mobilB/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fwww.**********.com%2FmobilB%2Fstorm-windows%2F and how do i fixed ? i let you know that i’ve changed my wordpress url and my website url and directory of my wordpress install from www.******.com/mobilB to www.******.com
I am not real fluent on c_Panel or the organization of things so not sure I am following what you are suggesting. If I follow all the steps in this article down to step 8 and don’t delete subfolder, are you saying I can’t use it as I am now as a development area? Are you saying instead that I should create another directory and move the the WordPress subfolder content to this directory. Isn’t the subfolder a database. It shows as a database in c_Panel. What is in my subfolder is not a subdomain so should I be creating a subdomain and coping my database to there?
Sorry for the confusion. First, your database is NOT in a folder on your website. It’s in a separate location on the server. WordPress references the database in wp-config.php. If you have ALL of the necessary files for running WordPress in a subfolder, then you can use that site as long as there is a separate database setup for that site. I test all the time using WordPress subdomain installations. As long as you have all the necessary elements for the WordPress installation to work (the WordPress core files, a wordpress database, and a properly configured wp-config.php file), then it shouldn’t be a problem to use the site as a test site. It doesn’t hurt to have another WordPress site for testing, but it’s not always necessary either. It will be up to your needs. If you have any further questions or comments, please let us know.
After coping Wordpress from a subfolder to root is it OK to leave the WordPress subfolder with the original WordPress files and use it as a test or development site? Will it cause any issues.
Moving a WordPress installation to a different location on your server can definitely cause the site to function differently. However, copying can be harmless if the content is copied to a different directory. If you’re going to use the copied files as your testing site make sure you create a database and database user with the appropriate privileges.
My WordPress Settings/General do not have the WordPress Address and Site Address fields – neither editable nor non-editabe. I tried to definte these variables by hand in the wp-config.php file, but I still get the WP install prefix the same as before. Why would these fields be missing, and how can I reconfigure WP so that it looks in public_html folder, rather than public_html/wp?
Sorry for the problem with the WordPress and Site address fields. If you’re not seeing the Address and site address fields in General, then it may be either theme or plugin related. Make sure you’re using the latest version of WP, and then make sure to use the default theme and no plugins. If you continue to have the same problem,then I would recommend re-installing WordPress. We would need more information about your installation – URL, version of WP, custom theme/plugins and also the steps (or URL) to see the problem you’re having.
I hope this helps to answer your question, please let us know if you require any further assistance.
Hi TJ, Thanks for your response. I did look at the error logs – they say there was a fatal php error on line 80 of my config.php. I am hosting on another server and followed your directions thinking they would work. Not sure how I would see anything wrong on my .htaccess file or on my index.php. Hosting service has been asked to restore files and server to before I attempted the move but it seems like they either don’t understand what I’m asking or don’t know how to do it or aren’t able. I’m sure if I knew just a little more I could untangle this mess!
I (thought) I followed these instructions but am getting a 500 Internal Server Error when I try to go to the site and a 403 Forbidden error when I try to log into the dashboard. Don’t know where to begin!
Are you able to see the apache logs? This would provide you with the direct issue regarding the 500 error. Generally the issue comes to either file permissions or something wrong in your .htaccess file.
unfortunately although i followed all the instructions my website is still not showing up. I copied all the files that were in my Test folder into the root (public_html)… after that i checked to see if my site was working, instead i only had a blank page appear…
i then accesed my db via phpadmin and exported my db, replaced all the urls from mydomain.com/test to mydomain.com , imported the new db after dropping all the tables first.
and still same result.
I should mention that oddly enough my domain.com/test is still loading properly :-/
Hi Scott, Im not sure what I did, however I seem to have managed to get it to upload properly using your previous comments this time (very strange). So sorry for sending the original query. Thank you for your past help, the tutorial is great to follow.
Hi Scott. I fixed the last problem I had importing the sql back, however this time nothing seems to fix it and I am freaking out as I need to get the site up and running today :-/
Im not sure if its the theme that I have used that may be causing the problem.
Can let me know what I am doing wrong please…
SQL query:
— — Dumping data for table `wp_commentmeta` — INSERTINTO`wp_commentmeta`(`meta_id`,`comment_id`,`meta_key`,`meta_value`) VALUES(1,1,‘_wp_trash_meta_status’,‘post-trashed’),(2,1,‘_wp_trash_meta_time’,‘1430279887’);
I recently moved my WP site from a subdomain/folder to the root. Now I’m wondering how to fix all the old broken links that I previously shared on my social media pages to (at the very least) redirect to my homepage. Thoughts? Thanks.
This is due to having data already in the database with that ID. When you export the database, set the Insert Ignore option. This will then add rows even if their ID exists. However it will delete the current ID and give it the next available one in line.
Sorry to hear you’re having problems with saving your theme. Can you tell us if you’re a customer? And if so, can you please provide the account information? It sounds like a permissions issue, but we can’t what the problem is without looking at the account.
If you have any further questions or comments, please let us know.
OK. Here is MY problem. I did everything EXCEPT delete the DEV folder (/test) The index page comes up. But when i click on another link OR try to Login, I get this:
Fatal error: Cannot redeclare jetpack_is_mobile() (previously declared in /home2/seamona/public_html/test/wp-content/plugins/jetpack/class.jetpack-user-agent.php:3) in /home2/seamona/public_html/wp-content/plugins/jetpack/class.jetpack-user-agent.php on line 59
Please help!!Everything is Broken now and I cant get it back!!
Are you able to get into the wp-admin area? Can you disable the plugin? You may need to disable them either in bulk, or using the same technique, disable the individual plugin folder.
Hi,
I’m not really ease with wp, it’s new for me. A quick question for you. I’m just starting the process and first problem when I tried to change the WordPress address (URI) and the Site Address address (URL). My adresses are example.com/test and not example.com/wordpress. I deleted /test at the end of both and when I saved, I received an error message:
Not Found
The requested URL /wp-login.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Thanks for the question. Actually, the error is normal. You’re just missing some of the steps required to finish that change. The link following the SITE URL option goes to this tutorial: Giving WordPress Its Own Directory. If you follow the steps here, then it will work properly. Sorry, it’s not too obvious in the Administrator – it’s something that I wish WordPress would fix myself.
I hope this helps to answer your question, please let us know if you require any further assistance.
Hi Arnel,
I ignored the error and continued the steps, but now seems to be worst…
The current website doesn’t work, all my folders of wp are writing on the page:
Index of /
It is difficult to determine what you’ve done based on what you’re showing me. If you are an InMotion Hosting customer, can you please provide your domain name. We can look at the account then help you resolve issue you’re facing. If you’re not a customer of InMotion, then we need to go BACK and look at the steps provided in the WordPress Codec to determine where things went wrong.
Please give us a little information so that we can provide further assistance for this issue.
Your best bet is probably simply to reset, remove all of the current files and then re-install WordPress. Otherwise, you will need to backtrack and undo what you’ve just done. Get back to the point where all you did was change the Site URL. Once you have done that then you can refer back to WordPress’s directions. I think that there was some misunderstanding with the directions starting at step 7.
I am not sure if I am missing a step in moving my WP files from a sub-directory in the root directory. There is a sentence that says removed the site files from the builder. How is this done? Currently I am at the step of backing up the files. I have not changed the URI or URL names yet
Sorry for the problems with the WordPress move. In order for us to help you, we need more information, please. If you can provide a URL that we could check, it would help us understand what’s happening. It also helps to know if you’re using any re-directs, plugins, or directory changes that may have affected the location of the WordPress Administrator. If you’re not sure, then you may need to troubleshoot the WordPress plugins, or check the WordPress database for the setting used for the WordPress Administrator.
Please provide us a little more information and we can investigate the issue further.
Nice guide, i moved my site from folder to root, but now no mails sent from wp. Post notifications, registration mails, lost password mail, doesn’t send at all. Any idea?
I followed this tutorial and the WP site is coming up fine, and can log in like normal so all is well EXCEPT the theme colors and background has changed back to default. So that didnt “move” with everything or something changed it.
I still have the subfolder with good design – but I cant log into that anymore either.
How do I get the theme, custom css, colors, skin to move to the root directory ?
Were you sure to copy everything from your /public_html/wordpress directory to just /public_html?
It also sounds like you could need to change the WordPress URL of your site if you forgot to change it prior to copying your WordPress site from a sub-folder to the root of your site.
A quick way to check is to place this highlighted code in your wp-config.php file:
// ** MySQL settings – You can get this info from your web host ** //
That should force things to load from the proper URL, as it’s usually a bad link to a CSS stylesheet that causes display issues after moving. If that fixes it, follow the other steps from that guide to make it permanent and remove the settings from your wp-config.php file.
If that’s not the problem, you might also have issues with content directly stored in the WordPress database using the sub-folder URL. In phpMyAdmin you could simply click on the Search tab and look for subfolder-name with at least one of the words and clicking on Select All and then Go.
Please let us know if none of that does the trick for you.
I just install it to my root directory of <https://odosta.com>ODosta</a> but I cannot cannot change my image path to root directory. please tell me how I can do it.
Automatically Export the Database from Source Server Transfering the files via FTP automatically Auto-import Database in Remote/destination server. Update .Htaccess properly Update wp-config.php file on destination server with the new credentials. Replace the URLs in Database (Posts, Pages, Menus…), and keep auto-update serialized objects too.
Just another reason that WordPress sucks badly. The other one WP being totally incapable of doing complete exports with images, templates and everything. With this much software bloat, why couldn’t anybody make WP easily movable, backupable and restorable?
Most CMSs, such as WordPress, Joomla, and Drupal will define your URL within it. This causes the additional changes to be made and is not something that is specific to WordPress.
I’m a student and gamer so recently I installeded wordpress at Takenbest Site but after sometimes, I need it to migrate to a sub domain but it showed database error, what should I do.
I can share its picture with error details but here no option to share photos.
Since it seems your database is not connected, I recommend following our guide on Configuring WordPress After a Migration. If your problems persist, our Live Support team is available to help.
Excellent guide! Still useful in 2022. Velvet blues did not help me, but this did.
Thanks Dan, glad to hear that you found it helpful!
Fantastic instructions
Thank you
I did have to install the “Search and Replace” plugin by InfoD74, to fix all of the image and link urls, which worked perfectly as well.
Worked perfectly at the first try. Thanks a lot for this.
wordpress was setup in mysite.com/wp/
but I cant find Administration -> Settings -> General.
Next, look for the WordPress address (URI): and change it from (example.com/WordPress to example.com)
Lastly, look for the Site Address address (URL): and change it from (example.com/WordPress to example.com)
Hello and sorry for your issue. In the WordPress dashboard you’ll see Settings on the left. If you do not see this, you may not have admin rights within that WordPress website.
Fantastic data collection, This is Work perfectly for me. I tried to do it on my site and had no issues. Thanks for sharing with us.
You’re welcome. We are always happy to help!
Thank you so much for this easy to follow guide! Worked perfectly for my site.
Glad we could help Susie!
Hello,
It’s Very usefull to me as I was looking for some tricks to transfer files to the root directory. Searched so many blogs but you guys are amazing on this job, and usally I don’t leave a comment but your article is so good and helpfull that I thought and writing this.
Again thanks for the simple trick, as I’m not going to use Duplicator plugin no more.
All the best!
Thank you for your feedback. We are glad that our content can help you!
Follow the tutorial step by step and now I have the error message ‘
Briefly unavailable for scheduled maintenance. Check back in a minute.’ on my wordpress site which I was intending to switch to.
How do I fix this?
You can usually remove the maintenance file (hidden file) from the main WordPress directory for your website to remove this.
This Method spoiled my project… Can you help me fix it
We would need more information to help you. Please provide details on the issue and we can try to help. You can also contact our live tech support team (contact info at the bottom of the page).
After i have update the wordpress and site URL, how can i go back and reverse it?
Also, i find something strange is that when i entered the URL, xxxx.com then it redirect to xxxx.com/subdirectory and i manually delete the subdirectory then it’s fine, is there anything or configuration in c-panel that i need to update?
Also, i do not know what is wrong on the mobile.
Thanks.
You would need to change the settings again with the updated URL to revert it back. We do not block mobile traffic explicitly, so I’m not sure why your phone would not see the site. Can you describe what you’re doing on your phone that is different from the computer? Note that WP does have a default area in the .htaccess file. If changes are made there or re-direct changes are applied above their code OR if another .htaccess file has precedence over the one for your WP site, then it can affect the behavior of the website. Also, if you make changes to the .htaccess file of your WP site then you should always make sure to clear the browser cache before trying to re-load the site in that internet browser.
Hi,
My url with the sub folder still shows up after i have moved all the files. Also, the site don’t appear in the mobile phone anymore.
How do i resolve that?
Thanks.
Ensure you have updated your “WordPress address (URL)” and “Site Address address (URL)” as described in the first section above. Also, test with another browser or clear your browser cache before testing.
Thank you,
John-Paul
I just wanted to let you know that I just did this and it worked beautifully!! Thank you – such a relief. The only hitches I had was links to some media files like pdf or video or audio files which I had to update. But overall, everything moved over like a dream. Thank you!
After doing the above steps, I get the error when I want to access any page
You don’t have permission to access /test2/index.php on this server.
Server unable to read htaccess file, denying access to be safe
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I recommend checking your .htaccess files stored on your server, as the error indicates that is the cause of the issue. However, since it does not specify the location of that file, you should check all the .htaccess files.
after doing all steps my wp admin deshboard is open but when i click site they show me your website is under construction how can i fix that?
It sounds like you may have an under construction plugin enabled or an index.html file your browser is defaulting to in your document root, i would recommend disabling any underconstruction plugins and removing any excess index files.
What is the differenc between this method and:
1. using Softaculous to make a clone in the root
2. Using WordPress toolkit, implement Move installation
3. Using the Duplicator Plugin reccomended by WP Beginner https://www.wpbeginner.com/wp-tutorials/how-to-properly-move-wordpress-to-a-new-domain-without-losing-seo/
Why would you choose one over the other?
The main difference is the guide above does not require a 3rd party plugin installation. But it is really a preference for you, as long as it works!
Thank you,
John-Paul
i have migrate https to www in phpmyadmin(wp-option). But the images url still pointing to https. How can change that to www? Help me to solve this please. Thanks in advance.
Yes, I advise following our guide on correcting image links after migration, which covers how you can search and replace old URLs, updating them to the new string.
The image URLs will need to be changed manually. You can do this on every page or post or do a search and replace in the database for instances of the old URL.
Hello! I have a main domain in my root folder and an addon domain (unrelated to the main domain) as a subfolder in the root. I made a dev subfolder in the addon domain, which is located as another subfolder in the root, alongside the addon itself. I want to move my dev subfolder to the root and delete the addon domain.
Do I need to take any extra steps in this situation? Will the files for the main domain interfere with the dev subfolder once I move it to the root?
Thanks so much in advance.
Hello Mila,
Thanks for the question about moving the dev folder. As long as it’s in the folder, there should be no interference with the other files. You will need to make sure that you change the root location for the subdomain if you have defined it as a subdomain in the cPanel. If not, then you don’t have to worry about it. If you have configurations which rely on the location of the dev folder then you may need to change the location of the folder.
I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
Hello Mila,
Thanks for the question about moving your dev folder. No extra steps are necessary. As long as the files remain in the folder then they shouldn’t interfere with anything else. Of course, there shouldn’t be a duplicate of the dev folder – otherwise, you’ll have a naming issue. If you have any configurations relying on the location of the dev folder then you will need to change the location to match where you have moved it.
I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
Thank you so much to tell us these steps…
Another question:
Since my WordPress website is currently still under www.example.com/wordpress/, all the internal links also contain /wordpress/. After I have followed the steps in your tutorial, will all the internal links change to URL’s without /wordpress/?
Hello Aya,
If you have hard links in a post or page, then you would need to update them. However, anything new will NOT have the subdirectory included in the path. After you have made the change, make sure that you are updating the permalinks in your WordPress installation.
If you have any further questions or comments, please let us know.
Regards,
Arnel C.
Hi,
I’m about to move my new WP website to the root and delete my current website, but I have a question. In my current .htaccess file I have a long list of redirects and this code:
options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://(www\.)?example.*(/)?.*$ [NC]
RewriteRule .*\.(avi|gif|jpg|jpeg|bmp)$ https://www.example.*/ [R,NC]
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} !^www\.example\.nl [nc]
rewriterule ^(.*)$ https://www\.example\.nl/$1 [r=301,nc]
(I have changed the name of my domain to ‘example’).
Now, in the current WordPress directory there is also a .htaccess file, which contains:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
Do I need to combine the two or is the WordPress htaccess code redundant once I moved the WP website to the root?
Create a file named index.php in your domain root with the following content….
define(‘WP_USE_THEMES’, true);
require(‘./Mainsite_New/wp-blog-header.php’);
Where Mainsite_New is your WordPress site folder name.
Enjoy!
RDS
Great tutorial – worked like a dream. I usually use Duplicator, which is free and also goo but this method is the easiest and fastest I;ve come across.
Thanks John-Paul! 🙂
hi, want to ask
if i wanna change my wordpress from blog.domain.com to domain.com/blog in iis with vb.net, is possible or not ?
anybody have a solution for this ?
thanks before
Here is a helpful link to our guide on how to change your WordPress URL.
Thank you,
John-Paul
Hi,
I completed all the steps. However if i goto my homepage www.xxx.com it still has my hosting providers page saying if you own this please upload to public_hmtl.
But if i goto www.xxx.com/aboutus that page will come up and so will the others, only the homepage wont?
The intro page may be index.htm or index.html and your first page is index.php. If that is the case, rename the index.htm or html page. This should allow the index.php page to show for your site.
hellow plz help me i transfered my site from local to live but i only see homepage
plz assist me on this am still on stack
Try going into the WP dashboard and updating your permalinks.
Don’t know if this impacts anybody (perhaps a note in the installation directions) but when I did the conversion try as I might I couldn’t get the wordpress changes to appear.
It suddenly occurred to me that my existing site uses index.htm andthe wordpress uses index.php. After renaming my existing index.htm Firefox now brings up my wordpress site.
Mark
Hi , I’m haveing a problem i’m using the web.com cpanel and i can’t get the files to the root and even i tried installing the wordpress direct to the root but it want let me , I tryed even serching on youtube but on web.com nobody has a video ( and web.com support want help me ) so what shoud i do ? i even tried on filezila and it want let me in
Unfortunately, it is difficult to say since I do not know the access levels of their setup. I do know on our servers, you have access to your files via cPanel File Manager, or FTP.
Thank you,
John-Paul
Hi.
I have moved my files from /dev/ to live but the ‘Home’ link on my navigation bar still goes to the dev site. The other links work okay.
Any ideas what is wrong?
Thanks
Stephen
Make sure to check if the Site and Home URL were updated after the move. You can add change this setting in the WordPress General Settings, as mentioned above in the section headed “Prepare your WordPress installation for the move”. You can also add set the Site and Home URL in the wp-config.php file to get the same effect.
could you please explain to me what this error is https://www.**********.com/mobilB/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fwww.**********.com%2FmobilB%2Fstorm-windows%2F and how do i fixed ?
i let you know that i’ve changed my wordpress url and my website url and directory of my wordpress install from www.******.com/mobilB to www.******.com
Hello karim,
Thank you for contacting us. I checked the link you provided, and am just getting a “page does not exist” message.
Is that the error you are getting?
If not, can you provide the full error message?
Best Regards,
John-Paul
Thanks man, you saved me from deadline day publishing.
Worked perfectly for me. I tried to do it on my site https://technosamigos.com and had no issues. Straightway 100% result.
Worked perfectly thank you so much!
I am not real fluent on c_Panel or the organization of things so not sure I am following what you are suggesting. If I follow all the steps in this article down to step 8 and don’t delete subfolder, are you saying I can’t use it as I am now as a development area? Are you saying instead that I should create another directory and move the the WordPress subfolder content to this directory. Isn’t the subfolder a database. It shows as a database in c_Panel. What is in my subfolder is not a subdomain so should I be creating a subdomain and coping my database to there?
Thanks
Hello Ken S.
Sorry for the confusion. First, your database is NOT in a folder on your website. It’s in a separate location on the server. WordPress references the database in wp-config.php. If you have ALL of the necessary files for running WordPress in a subfolder, then you can use that site as long as there is a separate database setup for that site. I test all the time using WordPress subdomain installations. As long as you have all the necessary elements for the WordPress installation to work (the WordPress core files, a wordpress database, and a properly configured wp-config.php file), then it shouldn’t be a problem to use the site as a test site. It doesn’t hurt to have another WordPress site for testing, but it’s not always necessary either. It will be up to your needs. If you have any further questions or comments, please let us know.
Regards,
Arnel C.
After coping Wordpress from a subfolder to root is it OK to leave the WordPress subfolder with the original WordPress files and use it as a test or development site? Will it cause any issues.
Moving a WordPress installation to a different location on your server can definitely cause the site to function differently. However, copying can be harmless if the content is copied to a different directory. If you’re going to use the copied files as your testing site make sure you create a database and database user with the appropriate privileges.
Great article! Everything is working great! I love step by step instruction. Very helpful!
My WordPress Settings/General do not have the WordPress Address and Site Address fields – neither editable nor non-editabe. I tried to definte these variables by hand in the wp-config.php file, but I still get the WP install prefix the same as before. Why would these fields be missing, and how can I reconfigure WP so that it looks in public_html folder, rather than public_html/wp?
Thank you!
Hello Colin,
Sorry for the problem with the WordPress and Site address fields. If you’re not seeing the Address and site address fields in General, then it may be either theme or plugin related. Make sure you’re using the latest version of WP, and then make sure to use the default theme and no plugins. If you continue to have the same problem,then I would recommend re-installing WordPress. We would need more information about your installation – URL, version of WP, custom theme/plugins and also the steps (or URL) to see the problem you’re having.
I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
Hi TJ, Thanks for your response. I did look at the error logs – they say there was a fatal php error on line 80 of my config.php. I am hosting on another server and followed your directions thinking they would work. Not sure how I would see anything wrong on my .htaccess file or on my index.php. Hosting service has been asked to restore files and server to before I attempted the move but it seems like they either don’t understand what I’m asking or don’t know how to do it or aren’t able. I’m sure if I knew just a little more I could untangle this mess!
Hello John,
Thank you for contacting us. Have you read our full guid eon the 403 Forbidden Error?
It provides additional troubleshooting information on the 403 error.
Thank you,
John-Paul
I (thought) I followed these instructions but am getting a 500 Internal Server Error when I try to go to the site and a 403 Forbidden error when I try to log into the dashboard. Don’t know where to begin!
Hello John,
Are you able to see the apache logs? This would provide you with the direct issue regarding the 500 error. Generally the issue comes to either file permissions or something wrong in your .htaccess file.
Best Regards,
TJ Edens
Hi and thanks for the tutorial…
unfortunately although i followed all the instructions my website is still not showing up. I copied all the files that were in my Test folder into the root (public_html)… after that i checked to see if my site was working, instead i only had a blank page appear…
i then accesed my db via phpadmin and exported my db, replaced all the urls from mydomain.com/test to mydomain.com , imported the new db after dropping all the tables first.
and still same result.
I should mention that oddly enough my domain.com/test is still loading properly :-/
what am i missing here?
Thank you in advance!
Hello Mark,
Have you tried reverting your theme back to the default 2014 theme? This is usually the cause for blank wordpress installations.
Best Regards,
TJ Edens
Hi Scott, Im not sure what I did, however I seem to have managed to get it to upload properly using your previous comments this time (very strange). So sorry for sending the original query. Thank you for your past help, the tutorial is great to follow.
Hi Scott. I fixed the last problem I had importing the sql back, however this time nothing seems to fix it and I am freaking out as I need to get the site up and running today :-/
Im not sure if its the theme that I have used that may be causing the problem.
Can let me know what I am doing wrong please…
SQL query:
—
— Dumping data for table `wp_commentmeta`
—
INSERT INTO `wp_commentmeta` ( `meta_id` , `comment_id` , `meta_key` , `meta_value` )
VALUES ( 1, 1, ‘_wp_trash_meta_status’, ‘post-trashed’ ) , ( 2, 1, ‘_wp_trash_meta_time’, ‘1430279887’ ) ;
MySQL said:
#1062 - Duplicate entry '1' for key 'PRIMARY'
informative and easy to follow!
Thank you. Its easier than i thought. Vey simply explained and easy to follow.
I recently moved my WP site from a subdomain/folder to the root. Now I’m wondering how to fix all the old broken links that I previously shared on my social media pages to (at the very least) redirect to my homepage. Thoughts? Thanks.
Hello Lindsay,
Thank you for your question. I recommend using 301 Redirects to fix the broken links.
If you are not good with coding .htaccess files, it may be easier to use one of the many 3rd party plugins available.
Thank you,
John-Paul
Hello Hodgie,
This is due to having data already in the database with that ID. When you export the database, set the Insert Ignore option. This will then add rows even if their ID exists. However it will delete the current ID and give it the next available one in line.
Kindest Regards,
Scott M
After moving my website to my hosting server, the theme options won’t save.
Hello Don,
Sorry to hear you’re having problems with saving your theme. Can you tell us if you’re a customer? And if so, can you please provide the account information? It sounds like a permissions issue, but we can’t what the problem is without looking at the account.
If you have any further questions or comments, please let us know.
Regards,
Arnel C.
OK. Here is MY problem. I did everything EXCEPT delete the DEV folder (/test) The index page comes up. But when i click on another link OR try to Login, I get this:
Fatal error: Cannot redeclare jetpack_is_mobile() (previously declared in /home2/seamona/public_html/test/wp-content/plugins/jetpack/class.jetpack-user-agent.php:3) in /home2/seamona/public_html/wp-content/plugins/jetpack/class.jetpack-user-agent.php on line 59
Please help!!Everything is Broken now and I cant get it back!!
Hello Maurice,
Are you able to get into the wp-admin area? Can you disable the plugin? You may need to disable them either in bulk, or using the same technique, disable the individual plugin folder.
Kindest Regards,
Scott M
Hi,
I’m not really ease with wp, it’s new for me. A quick question for you. I’m just starting the process and first problem when I tried to change the WordPress address (URI) and the Site Address address (URL). My adresses are example.com/test and not example.com/wordpress. I deleted /test at the end of both and when I saved, I received an error message:
Not Found
The requested URL /wp-login.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Any idea to help me? Thanks a lot!!
Hello Melanie2496,
Thanks for the question. Actually, the error is normal. You’re just missing some of the steps required to finish that change. The link following the SITE URL option goes to this tutorial: Giving WordPress Its Own Directory. If you follow the steps here, then it will work properly. Sorry, it’s not too obvious in the Administrator – it’s something that I wish WordPress would fix myself.
I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
Hi Arnel,
I ignored the error and continued the steps, but now seems to be worst…
The current website doesn’t work, all my folders of wp are writing on the page:
Index of /
license.txt
readme.html
wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-config.php
wp-cron.php
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php
When I try to go on the administration of the new website, I have this error message:
Not Found
The requested URL /wp-admin was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
In cpanel (File manager) the former files have been replaced by the new from wordpress but when I go to my FTP nothing changed. Any idea?
Hello Melanie2496,
It is difficult to determine what you’ve done based on what you’re showing me. If you are an InMotion Hosting customer, can you please provide your domain name. We can look at the account then help you resolve issue you’re facing. If you’re not a customer of InMotion, then we need to go BACK and look at the steps provided in the WordPress Codec to determine where things went wrong.
Please give us a little information so that we can provide further assistance for this issue.
Regards,
Arnel C.
Unfortunately I’m not a customer…
I’m totally lost, how to go back?
Hello Melanie,
Your best bet is probably simply to reset, remove all of the current files and then re-install WordPress. Otherwise, you will need to backtrack and undo what you’ve just done. Get back to the point where all you did was change the Site URL. Once you have done that then you can refer back to WordPress’s directions. I think that there was some misunderstanding with the directions starting at step 7.
Regards,
Arnel C.
very nice all that artilce , i read all and know what you want to say , and its will help me alot
hello im My Site Duniabd.com please unrevome the file directorye at duniabd.com please help me https://duniabd.com
Hello Shimanto,
I am not understanding what you are asking. Could you please respond with what it is you want to do step by step if possible?
Kindest Regards,
Scott M
Hello PaulaC,
To remove the builder files, you would simply delete them manually from within the cPanel file manager.
Kindest Regards,
Scott M
I am not sure if I am missing a step in moving my WP files from a sub-directory in the root directory. There is a sentence that says removed the site files from the builder. How is this done? Currently I am at the step of backing up the files. I have not changed the URI or URL names yet
Really Awesome Very Helpful Article ….Thanx…admin
Thanx, Very Helpful Article , Everything is perfect after moving my site to the main root according to the article instructions.
hi
i’ve completed everything fine till step 8 and my website is live showing all the wordpress stuff
but the next step where you said login to your new wordpress dashboard
example.com or example.com/wp-admin that is giving error
Hello Syed,
Sorry for the problems with the WordPress move. In order for us to help you, we need more information, please. If you can provide a URL that we could check, it would help us understand what’s happening. It also helps to know if you’re using any re-directs, plugins, or directory changes that may have affected the location of the WordPress Administrator. If you’re not sure, then you may need to troubleshoot the WordPress plugins, or check the WordPress database for the setting used for the WordPress Administrator.
Please provide us a little more information and we can investigate the issue further.
Kindest regards,
Arnel C.
nice for wordpress users and fans.
Nice guide, i moved my site from folder to root, but now no mails sent from wp. Post notifications, registration mails, lost password mail, doesn’t send at all. Any idea?
Hello Christ0fer,
Thank you for your question. In our guide on resetting your WP password via PHPmyAdmin, you can also update/view the Admin email.
In Step 5 of that guide, click Edit beside user_email to change it.
Feel free to post any additional questions below.
Thank you,
John-Paul
Folks …
Great info, moved without a glitch from subfolder to main domain > www.*****.cn
Did what I needed – thanks again
I followed this tutorial and the WP site is coming up fine, and can log in like normal so all is well EXCEPT the theme colors and background has changed back to default. So that didnt “move” with everything or something changed it.
I still have the subfolder with good design – but I cant log into that anymore either.
How do I get the theme, custom css, colors, skin to move to the root directory ?
Thanks!
Paul
Hey Paul,
Were you sure to copy everything from your /public_html/wordpress directory to just /public_html?
It also sounds like you could need to change the WordPress URL of your site if you forgot to change it prior to copying your WordPress site from a sub-folder to the root of your site.
A quick way to check is to place this highlighted code in your wp-config.php file:
define(‘WP_HOME’,’https://example.com’);
define(‘WP_SITEURL’,’https://example.com’);
// ** MySQL settings – You can get this info from your web host ** //
That should force things to load from the proper URL, as it’s usually a bad link to a CSS stylesheet that causes display issues after moving. If that fixes it, follow the other steps from that guide to make it permanent and remove the settings from your wp-config.php file.
If that’s not the problem, you might also have issues with content directly stored in the WordPress database using the sub-folder URL. In phpMyAdmin you could simply click on the Search tab and look for subfolder-name with at least one of the words and clicking on Select All and then Go.
Please let us know if none of that does the trick for you.
– Jacob
perfect. saved my life. perhaps explain how to do it with Filezilla rather than c-panel. Just found it a little easier to do it this way.
Include steps for multisite installation of wordpress
I just install it to my root directory of <https://odosta.com>ODosta</a> but I cannot cannot change my image path to root directory. please tell me how I can do it.
Hello Ahsan,
Do you have specific images that you are referring to? The images that I checked on your site have paths starting from the home directory.
Kindest Regards,
Scott M
Hi,
This a very useful article/tutorial, but I guess that there are other alternatives to the “manual” migration process.
I’ve seen several plugins like Duplicator that can help you migrate from server to server.
I’ve also developed another plugin for this, it’s a complete solution:
https://codecanyon.net/item/wp-golive/7793291?ref=RedhopIT
GoLive plugin has a lot of features:
Automatically Export the Database from Source Server
Transfering the files via FTP automatically
Auto-import Database in Remote/destination server.
Update .Htaccess properly
Update wp-config.php file on destination server with the new credentials.
Replace the URLs in Database (Posts, Pages, Menus…), and keep auto-update serialized objects too.
I hope it helps someone.
Regards,
Just another reason that WordPress sucks badly. The other one WP being totally incapable of doing complete exports with images, templates and everything. With this much software bloat, why couldn’t anybody make WP easily movable, backupable and restorable?
Most CMSs, such as WordPress, Joomla, and Drupal will define your URL within it. This causes the additional changes to be made and is not something that is specific to WordPress.
https://wordpress.org/plugins/velvet-blues-update-urls/ it will be helpful.