How do you set up a 301 redirect?

In your home directory (usually httpdocs) create a file labeled:

.htaccess

in it place these lines:


Options +FollowSymlinks
RewriteEngine on
rewritecond %{HTTP_HOST} !^(www\.)MYDOMAIN\.com$ [nc]
rewriterule ^(.*)$ http://www.MYDOMAIN.com/$1 [L,r=301,nc]

Replace "MYDOMAIN" with your actual domain name and save the file. That will send everyone who doesn't first go to www.mydomain.com to www.mydomain.com. For example if they go to:

http://mydomain.com 

they will be automatically redirected to:

http://www.mydomain.com

This also works if you have other domain names pointed at your main domain name. For example if myotherdomain.com is pointed to mydomain.com, then when someone visits:

http://myotherdomain.com (with or without the "www")

The will end up on:

http://www.mydomain.com

This can be useful for search engine optimization, since all of your various domains, with or without the "www", will all become one site as far as google or other search engines are concerned. All of your "link juice" will be consolidated into one result, instead of being dispersed over several different sites.

  • 22 Users Found This Useful
Was this answer helpful?

Related Articles

Where can I find formmail guides?

Here are some useful sites to help you get your FormMail working...

How does Webalizer track people visiting my site?

  Any request made to the server which is logged, is considered a 'hit'. The requests can be...

What is the full path to the cgi-bin?

/home/httpd/vhosts/domainname.com/cgi-bin Substitute your real domain name for...

How do I register a new domain name?

To order a new domain name, visit this page in the helpdesk:...

How do I transfer an existing domain name?

To transfer a domain to GlobalHost, visit this page in the helpdesk:...