Migrating wordpress cross domain changing URL

In practice needed to send a site “WordPress + Woocommerce” from localhost to a domain on the Internet, of course, changing all URLs that referred the images.

Problem

Had done on my machine (localhost) an online store using WordPress + Woocommerce and needed now to send it to the server on the Internet. But, It was necessary that all the URLs generated by the system when designing products and posts would point to the “localhost/MySite” and to refer to the new internet domain; Let's call it “meudominio.com/meusite”.

Is agreed, Like this:
– OLD URL: localhost/MySite (on my machine/local)
– NEW URL: meudominio.com/meusite (on my remote server/Internet)

Then, You must replace the sample URL, by your real URL.

ATTENTION: before you begin any of the procedures, back up your database and files. Is for your own risk!

Solution

I will not dive into “How to make” and Yes in the “to do”. Basically you must:

(1) Export to SQL using the local site PhpMyAdmin (or other tool to manipulate SQL);

(2) Create the new database on the server and import the SQL generated for the new domain;

(3) Send via FTP all the files from the local machine to the remote server;

(4) Open the file wp-config.php (at the root of your WordPress, from the server) and change the connection data with the new database;

(5) Still in the wp-config.php, Add these two lines:

  define(' WP_HOME ','http://meudominio.com/meusite ');
  define(' WP_SITEURL ','http://meudominio.com/meusite ');

(6) Open the file function.php (at the root of your WordPress theme, There/wp-content/themes/seutema Server) and add these two lines:

  update_option(' siteurl ','http://meudominio.com/meusite ');
  update_option(' home ','http://meudominio.com/meusite ');

(7) Finally, you need to change the URLs directly in the database. For this, Open your database using any manipulation tool, like phpMyAdmin, Select your database application and execute the following SQL (don't forget to change the example to your real domain):

1
2
3
4
5
6
  UPDATE wp_posts SET post_content = REPLACE (post_content, 
                              ' localhost/MySite ', 
                              ' meudominio.com/meusite ');

and also this SQL:

1
2
3
4
5
6
  UPDATE wp_posts SET guid = REPLACE (guid, 
                      ' localhost/MySite ', 
                      ' meudominio.com/meusite ');

I don't know if there is an easier way to do this, but this way I tested it and it works. Said, Good luck!

Source:

More details, view http://codex.wordpress.org/pt-br:Mudando_o_URL_do_Site

Total hits: 26256

3 comments on “Migrating wordpress cross domain changing URL

Leave a reply

The your email address will not be published. Required fields are marked with *