If you’re a WordPress developer/designer, especially a freelance developer, you know how beneficial it is to develop a site while it’s live. Not only is it helpful when debugging plugins/themes/etc…but it’s great to be able to give your clients a URL that will allow them to access the live site and view it for review purposes. Not only that, it’s awesome to be able to check a live site on a mobile phone and tablet too.

Did your client purchase hosting somewhere else for the new website? Cool, hopefully it was SiteGround WordPress Hosting. Now how do you develop new a WordPress website without any downtime of the current website? Easy, there are many ways to do it, but today I’m going to show you my general process to create a temp url when developing a website on the new server.

1. Install WordPress using the any domain name available during the installation process. Usually with apps like softaculous, they make it easy to setup and install right on the server in your chosen location. If it’s a new server and the only website, I like to install right on the root.

Afterwards you will have to configure the WordPress application with the temporary URL(which is either the shared IP or the server hostname).

2. After you have setup FTP, got to phpMYadmin and find the wordpress options table and replace siteurl and home with the new temp URL you want to use. You may want to use the IP address of the server you are on. So for example http://818.555.342.341/~newurl

Changing siteurl and home in phpmyadmin for worpdress url

3. Open .htaccess via FTP and find the following code in your file

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Now it should be changed to reflect the rewriting of the new URL:

RewriteEngine On
RewriteBase /~newurl/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~newurl/index.php [L]

Now open your website with the new temp domain you created. Build your new website and point the nameservers when your all done.

These are the steps I take when creating a temp URL for a client on a new server. When using an existing server, I just install WordPress in a subfolder and develop that way. It’s super easy to replace the current website on the root with the new website when ready.

Alternatively, you can force WordPress to read a new domain a couple different ways, but it may or may not work for everyone depending on their hosting environment and how they have setup everything. https://codex.wordpress.org/Changing_The_Site_URL

Adding this code to the functions.php file of the theme or child theme that is currently active.

update_option('siteurl','http://818.555.342.341/~newurl');
update_option('home','http://818.555.342.341/~newurl');

Adding this code to wp-config file.

define('WP_HOME','http://818.555.342.341/~newurl');
define('WP_SITEURL','http://818.555.342.341/~newurl');

When Switching to the New Domain

  • Change the DNS/Nameservers to the new server.
  • Check .htaccess and remove any caching code and any references to the temp domain.
  • Check wp-config.php file and make sure the new domain is set and not the temp domain.
  • Run a search and replace script to replace the old domain with the new one (for advanced users only)
  • If having any problems, check in phpmyadmin to make sure the domain was switched inside the options table for wp.