{"id":225,"date":"2017-07-16T22:12:13","date_gmt":"2017-07-16T22:12:13","guid":{"rendered":"http:\/\/jaipurhosting.com\/blog\/?p=225"},"modified":"2019-04-29T15:51:45","modified_gmt":"2019-04-29T10:21:45","slug":"migrating-wordpress-website-subdirectory-root-directory","status":"publish","type":"post","link":"https:\/\/www.jaipurhosting.com\/blog\/migrating-wordpress-website-subdirectory-root-directory\/","title":{"rendered":"Migrating wordpress website from subdirectory to root directory"},"content":{"rendered":"<p><strong>Description :&nbsp;<\/strong><\/p>\n<p>This method will work on a standard installation of WordPress, and will work with most frameworks, or if &nbsp;you\u2019re using a parent and child theme structure.<\/p>\n<p><strong>Note<\/strong> : This method will not work for multisite installations, only for standard single-site installations.<\/p>\n<p>&#8212;-<\/p>\n<p><strong>Step 1 :<\/strong> <em><strong>Remove the existing website<\/strong><\/em><\/p>\n<p>If there is an existing website in the root directory, remove it.<\/p>\n<p>It may be another WordPress installation or it may be a static website.<\/p>\n<p>If it\u2019s a WordPress website, make a backup as detailed above, and then delete all of the WordPress files in the<br \/>\nroot.<\/p>\n<ul>\n<li>If you have access to Softaculous or another installation service via your hosting control panel, use that<br \/>\nto uninstall WordPress.<\/li>\n<li>If not, use phpMyAdmin to drop (delete) the database from the existing website. See the next section for<br \/>\ndetails of how to do this.<\/li>\n<li>After dropping the database, remove all WordPress files. This normally means any files or folders beginning<br \/>\nwith <strong>wp-.<\/strong><\/li>\n<\/ul>\n<p><strong>Note<\/strong> : Don&#8217;t remove the existing site until you have made a backup.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 2<\/strong> : <em><strong>Turn OFF Permalinks<\/strong><\/em><\/p>\n<p>Turn off pretty permalinks in the \u201cPermalinks\u201d screen, which you\u2019ll find in the \u201cSettings\u201d menu.<\/p>\n<p>Do this by selecting the \u201cDefault\u201d option and clicking \u201cSave Changes.\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-226\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2-permalink.png\" alt=\"\" width=\"1246\" height=\"603\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2-permalink.png 1246w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2-permalink-300x145.png 300w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2-permalink-768x372.png 768w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2-permalink-1024x496.png 1024w\" sizes=\"auto, (max-width: 1246px) 100vw, 1246px\" \/><\/p>\n<p><strong>Step 3<\/strong> : <strong><em>Change your website Address<\/em><\/strong><\/p>\n<p>In \u201cSettings\u201d \u2192 \u201cGeneral,\u201d change the address of your website but not the address of WordPress.<\/p>\n<p>For example if you\u2019ve been working on the website at example.com\/development, change the settings as follows:<\/p>\n<ul>\n<li>WordPress address (URL): http:\/\/example.com\/development<\/li>\n<li>Site Address (URL): http:\/\/example.com<\/li>\n<\/ul>\n<p>Save by clicking on the \u201cSave Changes\u201d button and move on to the next steps before trying to access your<br \/>\nwebsite.<\/p>\n<p><strong>Step 4<\/strong> : <em><strong>Copy and Edit Two Files<\/strong><\/em><\/p>\n<p>Using FTP\/SFTP or cPanel file manager, copy (don\u2019t move) the following files from your WordPress directory to<br \/>\nthe root directory:<\/p>\n<ul>\n<li>index.php<\/li>\n<li>.htaccess, if you have one. If there isn\u2019t an .htaccess file (and turning off pretty permalinks means you\u2019re<br \/>\nless likely to have one), don\u2019t worry about creating one.<\/li>\n<\/ul>\n<p>Edit the index.php file that you\u2019ve moved. You could do this by:<\/p>\n<ul>\n<li>Editing it in site after the move, by using FTP\/SFTP or cPanel file manager<\/li>\n<li>Downloading it from the subdirectory, editing it and then uploading it to the root directory \u2014 instead of<br \/>\nmaking a copy.<\/li>\n<\/ul>\n<p>The edit you need to make is very simple, to one line at the end of the file. You simply change this:<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">require ('.\/wp-blog-header.php)<\/pre>\n<p>to<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true\">require ('.\/subdirectoryname\/wp-blog-header.php)\n<\/pre>\n<p>So if you\u2019ve been developing in example.com\/development, just change the line to:<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true\">require ('.\/development\/wp-blog-header.php)<\/pre>\n<p>Save the new <strong>index.php<\/strong> file.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 5<\/strong> : <em><strong>Turn Permalinks back on<\/strong><\/em><\/p>\n<p>Back in the WordPress admin, turn pretty permalinks on again, with whatever setting you need for your website.<\/p>\n<p>Visit the root domain of your website in the browser and it will display the website that\u2019s stored in the<br \/>\nsubdirectory, but the URL will show the root URL rather than the subdirectory URL<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description :&nbsp; This method will work on a standard installation of WordPress, and will work with most frameworks, or if &nbsp;you\u2019re using a parent and child theme structure. Note : This method will not work for multisite installations, only for standard single-site installations. &#8212;- Step 1 : Remove the existing website If there is an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1011,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-225","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=225"}],"version-history":[{"count":3,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/225\/revisions"}],"predecessor-version":[{"id":1574,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/225\/revisions\/1574"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media\/1011"}],"wp:attachment":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}