Problem with WWW in the url

Discussion in 'Apache' started by Dollar, Sep 14, 2007.

  1. #1
    The url http://somestie.com
    works

    but when going to http://www.somesite.com it is a blank page.

    How to fix this?

    Here is the V-host

    <VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot C://appserv/www/
    CustomLog logs/access.log common
    ServerName mysite.info
    ServerName www.mysite.info
    </VirtualHost>



    Never mind fixed it. just added http://www on it

    ServerName http://www.somesite.biz
    ServerName http://somesite.biz
     
    Dollar, Sep 14, 2007 IP
  2. sysadm

    sysadm Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi, you could also consider dropping the www part... just setup your server to redirect all such requests to domain.com. Some more information about this campaign at no-www.org
     
    sysadm, Sep 20, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Please explain sysadm? To redirect from www.domain.com, www.domain.com must be enabled first and this is done thee way Dollar done it.

    BTW, I'd use a ServerAlias for the www variant, not two ServerName's
     
    krt, Sep 21, 2007 IP
  4. qualityhostings

    qualityhostings Well-Known Member

    Messages:
    1,764
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    105
    #4
    I think there is an entry called ServerAlias, in linux.

    Not sure what about windows server?
     
    qualityhostings, Oct 12, 2007 IP
  5. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ServerAlias is an Apache directive and is independent of the operating system Apache is running on.

    I'm torn on the no-www.org issue. On the one hand, much of what they say is correct, web servers should definitely accept requests on both the bare domain and the www subdomain and may then choose whether to serve the page or redirect to www or the bare domain. www is annoying to type and even more so to say but many non-apache admins don't understand URLs without the www so it's more pragmatic to accommodate the majority of the world.

    krt is absolutely correct, if you aren't listening for www.domain.com then requests for it will simply timeout and you won't have any control over what happens to that user.

    On no-www.org they have an example of how you can redirect users once they have reached your webserver:

    RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

    but I prefer to use the slight variant:

    RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

    which allows you to add any number of ServerAlias directives and have them all redirect to the same, canonical URL.
     
    Ladadadada, Oct 13, 2007 IP