1. Home
  2. General Use and Troubleshooting
  3. Dynamic Redirects – .htaccess

Dynamic Redirects – .htaccess

These directives would be added to your .htaccess file, most likely at the start of this file.

Do you have a number of parked domains, but want them to all show the content of your main domain? The following directive may be suitable:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^parkeddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^parkeddomain-2.com$
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301]

Sometimes the easiest route might be just to redirect everything to a particular URL. If so, you could try the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.maindomain.com$
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301]

HTTPS Redirection

If you have your own SSL certificate already installed, the following directive will redirect all your traffic to the https:// version of your site:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

You can also use the built in CPanel redirect manager, however please note that all this does is append directives to your .htaccess

If you are unsure of using the above method, or need any further explanation, please open a technical support ticket so that we may assist.

Updated on April 28, 2021

Was this article helpful?

Related Articles