Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper way to re-direct?

If I have two domain names:

altcognito.com

and say I've got the other following domain:

alt-cognito.com

What's the "best" redirect (do I use permanent etc...?) I want to suggest that altcognito.com is the "correct" website.

(naturally, these are just examples)

like image 585
cgp Avatar asked May 03 '09 12:05

cgp


2 Answers

If you want to say that "you should always go to foo instead of bar," you want a 301 redirect (which you do with your front-end server). See http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93633

A 302 (temporary) redirect should be used in cases where you can't serve a page, but expect it to come back later. Unfortunately, it's the redirect that you get from JSP forward.

A client-side (meta refresh or javascript) redirect should be avoided whenever possible.

Edit per comment: here's a link to the Apache docs for configuring a permanent (or temporary) redirect: http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect

like image 59
kdgregory Avatar answered Nov 15 '22 04:11

kdgregory


<VirtualHost *:80>
    ServerAlias altcognito.com
    ServerAlias alt-cognito.com
    ServerAlias www.alt-cognito.com
    RedirectMatch permanent ^/(.*) http://www.altcognito.com/$1
</VirtualHost>

The 3 domains (www and non-www) will 301 redirect to your main domain www.altcognito.com

like image 20
cherouvim Avatar answered Nov 15 '22 04:11

cherouvim