简体   繁体   中英

Migrate wordpress site from subfolder to root, remove static page

My website have structure like this:

In root domain I have static html page "portfolio" (which I won't need it anymore, becauose I'll create it in wordpress):

http://www.natasamedvesek.com/

and I have installed wordpress for blog in subdirectory:

"natasamedvesek.com/blog/"

Now I have also all my pages structured like this "/blog/about" , "/blog/info" .... .

Now I'm asking what to do:

(1) move wordpress instalation from subdirectory "blog" to root directory.

or

(1) leave wordpress instalation as it is, in subdirectory "blog" and create redirect 301

My new structure would look like this:

"natasamedvesek.com" ---> portfolio "natasamedvesek.com/about" ----> page "about" "natasamedvesek.com/info" ----> page "info" . . .

"natasamedvesek.com/blog/" ---> page of postsIt's very important that I won't lost all my existing likes and shares from facebook, from all of my posts? What about my existing rank for SEO on google?

If I do create redirect 301, what I have to do?

Is this correct way, if I would put this code in .htaccess file

#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.natasamedvesek.COM/$1 [R=301,L]

Thanks for answers

It's much easier than using redirects; you can use the pre-existing subdirectory install and have admin at /blog/ while root appears to be at root.

From Giving WordPress Its Own Directory « Using a pre-existing subdirectory install

1) Go to the General panel.

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

3) Click Save Changes. (Do not worry about the error message and do not try to see your site at this point).

4) Copy (NOT MOVE!) the index.php and .htaccess files from the blog directory into the root directory of your site.

5) Edit your root directory's index.php. Open your root directory's index.php file in a text editor. 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__ ) . '/blog/wp-blog-header.php' );

and save the file.

6) Login to your site (if you aren't still already). The admin URL should still be http://www.natasamedvesek.com/blog/wp-admin/

7) 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 (in the same directory as the main index.php file.)

very important that I won't lost all my existing likes and shares from facebook...

You will lose your Facebook shares because the URL is changing, and there is no way to change an incoming Facebook link. And your SEO will take a temporary hit because you are changing URLs, at least until Google reindexes the site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM