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

  1. Log in to your hosting account via cPanel or File Manager.

  2. Navigate to the public_html directory.

  3. Locate and open the .htaccess file.

    • If it doesn’t exist, create a new file named .htaccess.

  4. Add the following directives (replace example.com with your domain and directory with 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]
    

     

  5. Save the file.

  6. Test by visiting your domain (e.g., http://example.com).

    • Your WordPress installation should now load directly.

 

Important Notes

  • Always back up your .htaccess file 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.

Hasznosnak találta ezt a választ? 0 A felhasználók hasznosnak találták ezt (0 Szavazat)

Powered by WHMCompleteSolution