简体   繁体   中英

Moving WordPress from subdomain to main domain

I've read the WordPress Codex instructions regarding moving WordPress, but none of the information provided seems to apply to my exact situation and I have a couple of questions before I go and break things. I have a main domain on which my old wordpress site is currently running (eg - example.com) I wanted to change the layout of the website but at the same time wanted to keep my main site running so made a subdomain (beta.example.com) and created my new wordpress website on this. Now I want to make my beta website the main website (ie make beta.example as example.com) and remove the main website, how do I go about that? I am using cpanel and both my folders are in the public html directory Thanks in advance.

Step 1: Backup: Always backup the files / database of the site(s) you choose to work with

Step 2: Move files: Delete the contents of example.com's document root and move the contents of blog.example.com to example.com

Step3: Change home/site-url: The daabase mght have other hard coded urls too. So changing the home / site url alone will not be enough and a full database search-replace is needed.

I would not recommend using notepad++ or any text editor to change the website url as it has a great chance to break the layout of the website and I have seen it may times happen. I always use and recommend you to use the Database Search and Replace Script from here

Download the version 2.1.0 to the document root of the website as search.php

Now call the script via your browser (as domain.com/search.php). The script autopopulates the database details. The rest of the instructions there are self explanatory to follow.

Step 4: Finishing up: Check the .htaccess file that there are no redirects to the blog.example or similar redirects. If yes, remove them and replace with the default .htaccess wordpress rules.

That should do it.

Steps are below:-

  1. Make a new folder into your root in Cpanel and move your old domain(example.com) files to the new folder as a backup
  2. Move your subdomain (beta.example.com)folder's files into root in cpanel
  3. rename your ht access file it will automatically created when your WordPress run into the browser.
  4. Into your PHPMyAdmin create new database (like new_database)
  5. Download your subdomain database and open it into editor something (like notpad++)
  6. Into notpad++ press crt+f, from tabs click to replace, into find section put beta.example.com and into replace with section put example.com then save it make sure you do not use HTTP, https or www when performing the replacing task.
  7. Now goto your WordPress directory wp-config file and change your database name with newly created one username and password too.
  8. Visit example.com/wp-admin login there with your login details you were using to login into beta.example.com/wp-admin.
  9. Into deshboard->setting click to permalinks and select %%postname%%

Thanks, I hopes it will work for you as example.com

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