.htaccess » How to access WordPress using temporary server URL

How to access WordPress using temporary server URL

We occasionally find ourselves in a situation where we need to test the website first, then point the domain name if everything is in order.

To achieve this there are multiple ways:

  • Edit Hosts file on your local computer
  • Use online service such as skipDNS
  • Access WordPress using temporary server URL

In this guide We will be using the third method and show how to access WordPress using temporary server server URL.

The link will be in the format: http://serverhostname.com/~cpanel_username/

To achieve this We will edit two files:

From cPanel > File Manager edit the wp-config.php file and add the following lines to it:

define('WP_HOME','https://serverhostname.com/~cpanel_username/');
define('WP_SITEURL','https://serverhostname.com/~cpanel_username/');

Save the file and edit the .htaccess file:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~cpanel_username/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~cpanel_username/index.php [L]
</IfModule>

# END WordPress

That’s it, your website is now accessible via: http://serverhostname.com/~cpanel_username/

You can test it before changing DNS, and if everything is OK don’t forget to remove changes made to those two files.

See also  Delete Expired WordPress Transients 🚮

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended