AlbertJames
AlbertJames

Reputation: 13

Change URL on Wordpress

I have been working on a WordPress site. www.example.com and the main homepage of my site(index.html) says "We're under construction etc." and it's just an image.

For the development of the website, I have been using a different directory - www.example.com/dev and everything I have developed has been under /dev(/dev/index.php etc.)

The website is now ready and I need to point the finsihed website (www.example.com/dev) to the actual public site(which is now under www.example.com) that I have finished. How do I go about this?

Upvotes: 0

Views: 2334

Answers (4)

Asakkour Soufiane
Asakkour Soufiane

Reputation: 514

use this code for changing you website url

SET @oldsite='http://www.example.com/dev'; 
SET @newsite='http://www.example.com';
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite);
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite);

Upvotes: 1

Mukesh Ram
Mukesh Ram

Reputation: 6338

This can be done 2 ways,

  1. You can do this easily by changing site_url in options table. Once you transfer data and change the url your site should be running on the new url. If you have stored static urls in post or pages then, you have to change that as well.
  2. Export sql file from phpmyadmin. Now find and replace all urls from old to new ones.

Note: Keep your current development site working as, sometimes it's possible that contact form 7 or any data gets missing. For example, Widgets get in inactive mode sometime.

Once your new website is confirmed then you can remove your old website.

Upvotes: 0

Randy
Randy

Reputation: 9849

Moving Directories On Your Existing Server

Wordpress has a wiki page that explained this for you:

Moving Wordpress

Here are the step-by-step instructions to move your WordPress site to a new location on the same server:

  1. Create the new location using one of these two options:

    1. If you will be moving your WordPress core files to a new directory, create the new directory.

    2. If you want to move WordPress to your root directory, make sure all index.php, .htaccess, and other files that might be copied over are backed up and/or moved, and that the root directory is ready for the new WordPress files.

  2. Log in to your site.

  3. Go to the Administration > Settings > General panel.

  4. In the box for WordPress Address (URL): change the address to the new location of your main WordPress core files.

  5. In the box for Site Address (URL): change the address to the new location, which should match the WordPress (your public site) address.

  6. Click Save Changes.

  7. (Do not try to open/view your site now!)

  8. Move your WordPress core files to the new location. This includes the files found within the original directory, such as http://example.com/wordpress, and all the sub-directories, to the new location.

  9. Now, try to open your site by going to yourdomain.com/wp-admin. Note, you may need to go to yourdomain.com/wp-login.php

  10. If you are using Permalinks, go to the Administration > Settings > Permalinks

    panel and update your Permalink structure to your .htaccess file, which should be in the same directory as the main index.php file.

  11. Existing image/media links uploaded media will refer to the old folder and must be updated with the new location. You can do this with the Better Search Replace plugin, WP-CLI's search-replace if your hosting provider (or you) have installed WP-CLI, manually in your SQL database, or by using the 3rd party database updating tool Search and Replace Databases Script * Note: this script is best used by experienced developers.

  12. In some cases your permissions may have changed, depending on your ISP. Watch for any files with 0000 permissions and change them back to 0644.

  13. If your theme supports menus, links to your home page may still have the old subdirectory embedded in them. Go to Appearance > Menus and update them.

  14. Sometimes you would need to restart your server, otherwise your server may give out an error. (happens in MAMP software (Mac)).

  15. It is important that you set the URI locations BEFORE you move the files.

If You Forget to Change the Locations

If you accidentally moved the files before you changed the URIs: you have two options.

  1. Suppose the files were originally in /path/to/old/ and you moved them to /path/to/new before changing the URIs. The way to fix this would be to make /path/to/old/ a symlink (for Windows users, "symlink" is equivalent to "shortcut") to /path/to/new/, i.e.

    ln -s /path/to/new /path/to/old

    and then follow the steps above as normal. Afterwards, delete the symlink if you want.

  2. If you forget to change the WordPress Address and Blog Address, you will be unable to change it using the wordpress interface. However, you can fix it if you have access to the database. Go to the database of your site and find the wp_options table. This table stores all the options that you can set in the interface. The WordPress Address and Blog Address are stored as siteurl and home (the option_name field). All you have to do is change the option_value field to the correct URL for the records with option_name=’siteurl‘ or option_name=’home‘.

Upvotes: 0

Devsi Odedra
Devsi Odedra

Reputation: 5322

step 1:

Just copy your all files and folder from www.example.com/dev to www.example.com

step 2: open your database and in table wp_option

siteurl http:// www.example.com/dev to www.example.com/

home http:// www.example.com/dev to www.example.com/

Upvotes: 0

Related Questions