> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Redirecting the main domain to an existing WordPress install

> Configure your account to automatically redirect your primary domain to your WordPress site installed in a subdirectory.

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](http://www.example.com/wordpress-test)* to view the WordPress site, you want to be able to just go to *[http://www.example.com](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.

## 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](http://www.example.com)* ). The WordPress installation should appear.

## Related articles

* [Using .htaccess files](/docs/using-htaccess-files)

* [Editing .htaccess files](/docs/editing-htaccess)
