12 Dec 2024 
Support Center » Knowledgebase » How do I force my website visitors to be redirected to my main website domain name?
 Login [Lost Password] 
Email:
Password:
Remember Me:
 
 Search
 Article Options
 How do I force my website visitors to be redirected to my main website domain name?
Solution You can configure your website to automatically redirect its visitors to one central domain name. This is done with a few lines of code in an ".htaccess" file, file found in your "/var/www/html" (or your "mainwebsite_html") directory. If that file does not exist already, you can create a blank file and name it ".htaccess".

** Warning: modifying this .htaccess file can potentially bring your website down or cause unintended results. Be sure to back this file up before making any changes.

You will want to put in the following code (replacing "DOMAIN.COM" with your domain name):

#--- Start Redirect Code
RewriteEngine On

# Handles regular requests
RewriteCond %{HTTP_HOST} !^www.DOMAIN.COM$ [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ http://www.DOMAIN.COM/$1 [R=301,L]

# Handles SSL-page requests
RewriteCond %{HTTP_HOST} !^www.DOMAIN.COM$ [NC]
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ https://www.DOMAIN.COM/$1 [R=301,L]
#---/End Redirect Code




Article Details
Article ID: 9
Created On: 17 Aug 2006 08:40 PM

 This answer was helpful  This answer was not helpful

 Back
Home | Register | Knowledgebase | News | Downloads
Language:

Help Desk Software By Kayako SupportSuite v3.70.02