How to redirect the primary domain to an existing WordPress installation

This article describes how to redirect the primary domain to an existing WordPress installation.

For example, you might install WordPress into a subdirectory on your account for testing and development. Later on, however, you want to continue using this installation as the WordPress site for your primary domain. In other words, instead of going to http://www.example.com/wordpress-test to view the WordPress site, you want to be able to just go to http://www.example.com and see the WordPress site.

To do this, you can configure redirection in the .htaccess file in the public_html folder.

Table of Contents

Configuring redirection

To configure redirection to the existing WordPress installation, copy and then paste the following directives into the .htaccess file located in the public_html directory. Make sure you replace occurrences of example.com with your own domain name, and occurrences of directory with the name of the directory where you previously installed WordPress:

RewriteEngine on

# Change "example.com" to your own domain name:
RewriteCond %{HTTP_HOST} ^(www.)?example.com$

# Change "directory" to the directory where WordPress is installed:
RewriteCond %{REQUEST_URI} !^/directory/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change "directory" to the directory where WordPress is installed:
RewriteRule ^(.*)$ /directory/$1

# Change "example.com" to your own domain name:
RewriteCond %{HTTP_HOST} ^(www.)?example.com$

# Change "directory" to the directory where WordPress is installed:
RewriteRule ^(/)?$ directory/index.php [L]

After you make these modifications, use your web browser to load your domain name (for example, http://www.example.com). The WordPress installation should appear.

Get WordPress Hosting

Article Details

  • Operating System: Linux Hosting
  • Level: Intermediate

Other Articles in This Category

Show More

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.