Possible to redirect domain.com to www.domain.com?


#1

I have a blog site, I always want domain.com to redirect to www.domain.com, is this possible? I can’t add www.domain.com as a subdomain either, so what else can I do? Thanks.


#2

why does it matter?

[color=#0000CC]jason[/color]


#3

I just want it to be consistent throughout the site. My last host allowed this, Dreamhost should too I think. I prefer how it looks in the address bar as well, again, for consistency’s sake.


#4

you can reach the site from either address correct? I don’t see the problem, or a solution to what you seem to want. Sorry I stuck my head in :wink:

[color=#0000CC]jason[/color]


#5

Two ideas:

  1. Ask support
    They control the server configuration and might be able to make this change.
  2. Use URL re-writing to check the HTTP_HOST variable; for HTTP/1.1 it contains the hostname the user agent is asking for.

:cool: Perl / MySQL / HTML+CSS


#6

I think that is a waste of time. You’d be better off doing it the other way around, anyway. There is no need to have a www in front of a web address, just as there is no need to have someone@mail.domain.com for an email address. Add this to your .htaccess file to get rid of the www, changing domain and tld as needed:RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC] RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]--------------------
Simon Jessey
Keystone Websites | si-blog


#7

Though, there is kind of a longstanding tradition to have the “canonical” form of a Web address be the one with “www.” in front of it.

Personally, my own sense of aesthetics is best served by having the “www.” in front of a simple domain address (“example.net”) but leaving it out if there’s already a subdomain or hostname in the address (“site1.example.net”). Thus, I use http://www.dan.info/, but http://webtips.dan.info/ without the www for the subdomain-based web tips site.

– Dan