[CentOS] DNS Setting

Mon Feb 20 06:05:49 UTC 2006
Bruno S. Delbono <Bruno.S.Delbono at Mail.AC>

str tux wrote:
> Hello People,
> In my DNS setting I added A record of www for our company website.
> It works, when you go to http://www.mycompany.com; it resolves and it
> shows the website content.
> But in addition, I want also some kind of redirection or mapping (i
> don't know what you called that) that when people go to
> http://mycompany.com (without www), it should forward also to the www
> server.
> How to do it? Thanks in advance.

If you are using apache as the webserver, you can create a redirect to it:

Here is an apache2 mod_rewrite example:

# For sites running on a port other than 80
RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*) 
http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]

# And for a site running on port 80
RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://fully.qualified.domain.name/$1 [L,R]

More Info:


If you are running any other webserver...check it's docs.

Warm Regards,

Bruno Delbono
Open-Systems Group