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.
S.Tux
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:%%7BSERVER_PORT%7D/$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.
Warm Regards,
-- Bruno Delbono Open-Systems Group http://www.open-systems.org/users/bruno/
Thanks Bruno.
I'm so sorry for restating it again my situation before trying it; the situation like this:
Right now, when you go to http://mycompany.com it goes to nowhere since it doesn't resolve to any IP address.
I'm thinking, we can do it in the DNS that when someone trying to access http://mycompany.com it should resolve to www host.
Thanks.
S.Tux
On 2/20/06, Bruno S. Delbono Bruno.S.Delbono@mail.ac 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:%%7BSERVER_PORT%7D/$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.
Warm Regards,
-- Bruno Delbono Open-Systems Group http://www.open-systems.org/users/bruno/
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
str tux wrote:
I'm thinking, we can do it in the DNS that when someone trying to access http://mycompany.com it should resolve to www host.
You mean a CNAME?
mycompany.com. IN CNAME www.mycompany.com.
or
@ IN CNAME www.
-- Bruno Delbono Open-Systems Group http://www.open-systems.org/users/bruno/
Thanks Bruno. It works.
S.Tux
On 2/20/06, Bruno S. Delbono Bruno.S.Delbono@mail.ac wrote:
str tux wrote:
I'm thinking, we can do it in the DNS that when someone trying to access http://mycompany.com it should resolve to www host.
You mean a CNAME?
mycompany.com. IN CNAME www.mycompany.com.
or
@ IN CNAME www.
-- Bruno Delbono Open-Systems Group http://www.open-systems.org/users/bruno/ _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Sunday 19 February 2006 22:26, Bruno S. Delbono wrote:
You mean a CNAME?
mycompany.com. IN CNAME www.mycompany.com.
or
@ IN CNAME www.
--
Just to clarify, the latter line in the example above (starting with @) would bomb, since the period at the end would terminate the name of the CNAME ref, and so the mycompany.com domain name would not be appended. You'd want either
@ IN CNAME www.mycompany.com.
// OR //
@ IN CNAME www
I prefer to set it the other way around, EG:
@ IN A 1.2.3.4 www IN CNAME @
and then set up apache with ServerAlias for the www.domain.com entry.
-Ben
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:%%7BSERVER_PORT%7D/$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@wieers.com, http://dag.wieers.com/ -- [all I want is a warm bed and a kind word and unlimited power]
Quoting str tux str.tux@gmail.com:
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.
Make either A or CNAME record pointing to your web server (like you did for www.foobar.com). This will not affect email delivery for @foobar.com as long as you have MX record for it (MTA are supposed to search first for MX, then fall back to A and/or CNAME only if MX does not exist).
This will work, but you might also want to do this additional (mostly cosmetic) step. In Apache configuration, define redirection so that when people hit "foobar.com" they get redirected to "www.foobar.com". I've read somewhere that some search engines might penalize your site if they find "duplicate" content (like foobar.com and www.foobar.com being identical). I've no idea if this is just urban legend or some search engines really do that (would be nice if somebody can either confirm this, or tell if it is just a myth). However, myth or no myth, some stuff in Apache configuration gets simpler if you don't need to manage support for both foobar.com and www.foobar.com, and to be on the safe side, placing something like this in /etc/httpd/conf.d/rewrite.conf should work:
RewriteEngine On RewriteRule ^http://foobar.com(.*)$ http://www.foobar.com$1 [L,R=permanent]
You could place the above two lines into main httpd.conf file too. I simply find mora managable to have my additional stuff in separate files. If you are already using rewriting rules, you probably already have the "RewriteEngine On" line. In that case, just add RewriteRule wherever your other rewriting rules are (see Apache documentation for more details and description of L and R flags).
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.