user450_user
user450_user

Reputation: 107

WordPress - move blog from root to subdirectory

I have genesis template of WordPress and I have there a blog x.com/blog

but now I created a folder blog - subdirectory with new WordPress installation in the root and I want the the sit : x.com/blog will work with the new blog. new WordPress site /installation -- the homepage works but all the category and posts redirected to the old one

I try to add rules to htaccess and i tried to add "blog" to index php before the blog-template.php in index php - it is working but the old site now is not works at all.

so how can I do that ?

thx

Upvotes: 1

Views: 1648

Answers (2)

markratledge
markratledge

Reputation: 17561

It sounds like you have one WordPress install and you want to move it from root to /blog? Or do you have two installs?

If you have one install, you need to move the original .htaccess file and move and edit the index.php file, as well as save permalinks once you've complete the move.

The complete instructions from https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Moving_a_Root_install_to_its_own_directory :

1) In Settings, change the box for WordPress address (URL): change the address to the new location of your main WordPress core files. Example: http://example.com/wordpress

2) In the box for Site address (URL): change the address to the root directory's URL. Example: http://example.com

3) Save Changes. (Do not worry about the error message and do not try to see your blog at this point! You will probably get a message about file not found.)

4) Move your WordPress core files to the new location (WordPress address).

5) Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog address). The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are not using pretty permalinks, then you may not have a .htaccess file.

(If you are running WordPress on a Windows (IIS) server and are using pretty permalinks, you'll have a web.config rather than a .htaccess file in your WordPress directory. For the index.php file the instructions remain the same, copy (don't move) the index.php file to your root directory. The web.config file, must be treated differently than the .htaccess file so you must MOVE (DON'T COPY) the web.config file to your root directory.)

6) Open your root directory's index.php file in a text editor

7) Change the following and save the file. Change the line that says: require( dirname( __FILE__ ) . '/wp-blog-header.php' ); to the following, using your directory name for the WordPress core files: require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' ); Login to the new location. It might now be http://example.com/wordpress/wp-admin/

8) If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file

Upvotes: 2

Robert Morel
Robert Morel

Reputation: 47

This is a simple move but it seems to work 70% of the time:

Go to Dashboard -> Settings -> Permalinks

Go down to the bottom and click "save".

WordPress will regenerate your links.

If this doesn't work then try a plugin that regenerates links.

Upvotes: 0

Related Questions