Madhurie Singh . Com

How to build my own web site from my wordpress blog !

Migrating wordpress from root to subdirectory on webhost!

Posted by Madhurie Singh on September 7, 2009

Tonight I will make a subdirectory for wordpress files to keep the root directory clean.

My root i.e. /public_html has all wp_ files that were created after SimpleScripts installed wordpress. Then other files were added after I imported wordpress.date.xml file through my wordpress site admin page.

I am creating a subdirectory say ONLY4KIDS where all my wordpress files will be moved.

I go to my CPanel and make a new directory under public_html. I name it as Only4kids.
Then I select all files except index.php and .htaccess files and move them into subdirectory Only4Kids.

move all wordpress files to subdir

The subdirectory is created.
created now subdirectory for wordpress

Now I need to change the link address from http://www.madhuriesingh.com to http://www.madhuriesingh.com/Only4kids throughout my database.

For that I Click phpmyadmin in CPanel. Then I click the database connected with this wordpress. In my case it is madhurie_wrd01.
I then select all the tables preceding with wp_ .
select all tables in original table and export

Then I click EXPORT button on top. An sql file containing all my database details and content is downloaded to my laptop. This file is madhurie_wrd01.SQL
exporting the tables to change wordpress to subdirectory

Now I open this SQL file in an editor and find all http://www.madhuriesingh.com with http://www.madhuriesingh.com/only4kids.
I save this sql file.
change all urls to new url with subdirectory

Before I upload it back to the database, I select all the tables and drop them.
drop all tables and import the file which has updated url

Now I click IMPORT and select the updated SQL file madhurie_wrd01.SQL
import all updated tables in database

So now all places where the reference to http://www.madhuriesingh.com are changed to http://www.madhuriesingh.com/only4kids

Now I need to change the index.php file line 17. The index.php file should be in the root directory where I change this line 17.

I change line 17 ie require(‘./wp-blog-header.php’); to require(‘.only4kids/wp-blog-header.php’);

But I get this error message when I load my site http://www.madhuriesingh.com

Warning: require(.only4kid/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home8/madhurie/public_html/index.php on line 17

Fatal error: require() [function.require]: Failed opening required ‘.only4kid/wp-blog-header.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home8/madhurie/public_html/index.php on line 17

Lemme try to change the path in settings on the wordpress admin page.

OOPS 😦 !!!!
I am getting same error message here too !!!!!!!!!!!!!!!

Ok lemme guess, maybe the path has some minor error.

I will rewrite line 17 of index.php with a front slash before the subdirectory only4kids
require(‘.only4kids/wp-blog-header.php’); to require(‘./only4kids/wp-blog-header.php’);

I save the index.php file and load my site again.

YIPPPPPYYYY it works!

There is my baby .
mysite after migrating to subdirectory

reference
http://sandboxblogger.com/giving-wordpress-its-own-directory/comment-page-1/#comment-1890

Advertisements

One Response to “Migrating wordpress from root to subdirectory on webhost!”

  1. WORDPRESS MIGRATION

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: