[CentOS] DNS Setting

Dag Wieers dag at wieers.com
Mon Feb 20 06:38:51 UTC 2006


On Sun, 19 Feb 2006, Bruno S. Delbono wrote:

> 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:
> 
> http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
> 
> If you are running any other webserver...check it's docs.

It's probably better for your webserver to simply do:

	<VirtualHost *:80>
	        ServerName dag.wieers.be
	        ServerAlias www.dag.wieers.com www.dag.wieers.be
	        Redirect Permanent / http://dag.wieers.com/
	</VirtualHost>

Since the Redirect is restricted to the VirtualHost and there are no 
expensive regular expressions involved.

Kind regards,
--   dag wieers,  dag at wieers.com,  http://dag.wieers.com/   --
[all I want is a warm bed and a kind word and unlimited power]



More information about the CentOS mailing list