If you installed WordPress in a subdirectory (e.g., example.com/wordpress-test) for testing or development, you may later want to use that installation as your primary site. Instead of reinstalling WordPress in the root, you can configure your domain to redirect directly to the existing WordPress installation. On ruachost.com, this is done by editing the .htaccess file.
Why Redirect?
-
Avoids reinstalling or migrating WordPress.
-
Lets you keep your tested/developed WordPress site as the main site.
-
Ensures visitors access WordPress directly at your domain name.
Steps to Redirect Main Domain
-
Log in to your hosting account via cPanel or File Manager.
-
Navigate to the public_html directory.
-
Locate and open the
.htaccessfile.-
If it doesn’t exist, create a new file named
.htaccess.
-
-
Add the following directives (replace
example.comwith your domain anddirectorywith your WordPress folder name):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 ## Redirect all requests to WordPress directory: RewriteRule ^(.*)$ /directory/$1 ## Redirect root domain to WordPress index: RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ RewriteRule ^(/)?$ directory/index.php [L] -
Save the file.
-
Test by visiting your domain (e.g.,
http://example.com).-
Your WordPress installation should now load directly.
-
Important Notes
-
Always back up your
.htaccessfile before editing. -
Incorrect rules may cause site errors or redirect loops.
-
If using caching/CDN, clear cache after making changes.
-
SSL/HTTPS sites may require additional rules to enforce secure connections.