
Transfer WordPress to Other Server
This is very often a situation where you need to transfer WordPress from one server to another server. Below are steps, by which this thing can be done most easily.
- Transfer all files to other server where you will need to set up WordPress.
- Go to wp-content/wp-config.php, set database name, username, password, and hostname.
- Open the database, go to wp_options table, set site_url value and home .. both this option will have value will have new server home URL. In case if you want to setup it for the local server then give a URL address for the local server http://localhost/abc. site_url has option_id value is 1 and home has option_id value is 37 if you would like to locate them quickly.
- Now next thing, if already website has posts or pages.. then we may need to change its URL. We are not going to entertain this thing by one by one record instead of we will fire a query to make life easier. We need to change the value guide in the wp_post table… suppose the older server address is abc. com and the new server are xyz.com then the below query will replace all value of URL of abc.com to xyz.com. You can repeat the below process for the post_content field in wp_post as per your need.
- So in this way, we have converted all older server’s URL by new one.Lastly, check the .htaccess file at the root folder. Add folder location as per your need Suppose my website at the local server. Its location is in abc folder then .htaccess code will look like as below
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /abc/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /abc/index.php [L] </IfModule>
If the website at the root folder then codes no need to put folder location in RewriteBase and Rewrite Rule. Code will look like<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ./index.php [L] </IfModule>
Note: Please ignore .htaccess related change if you don’t want Permalink in custom structure folder. If Permalink is set with the default option, then .htaccess related changes not required.That’s all. You have done it.