Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

I would like to redirect my web site this way: -->

how can I achieve it in apahce on centos linux?

share|improve this question

marked as duplicate by coredump, EEAA, Chopper3 Apr 15 '11 at 11:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

That type of redirect is probably better done with DNS. Make a CNAME entry for and put an A record in the entry.

share|improve this answer

mod_rewrite is capable of doing it, as well as using a ServerAlias directive if you use vhosts.

share|improve this answer

Canonical Hostnames

Description: The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of instead of, you might use a variant of the following recipe. Solution:

# For sites running on a port other than 80
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*){SERVER_PORT}/$1 [L,R]

# And for a site running on port 80
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)$1 [L,R]
share|improve this answer

You could do an htaccess redirect.

share|improve this answer
Placing the relevant parts in your answer from the link is recommended. – Lucas Kauffman Jul 21 '12 at 13:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.