Forum Moderators: phranque

Message Too Old, No Replies

Configuring conf file. using www or not in URL

         

rothdavid

1:47 pm on Nov 27, 2008 (gmt 0)

10+ Year Member



Hi, I am fairly new to apache server and I have a beta WAMP server set up at home. (apache 2.2)

I have two sites pointing to the server. If I use the urls without www. in front of it, apache directs the request to the right subfolder, if I use www.sitename.com then it drops it to the root folder (The first folder it comes across in the conf file)

How do you write the VirServer confirguration so it directs to the appropriate folder whether the URL has WWW or not?

This is what I have in my conf file.

<VirtualHost 192.168.1.12>
ServerName mysitename.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/mysitename"
</VirtualHost>

When I use www.mysitename.com in the URL, it directs to the root folder htdocs, if I remove the www. it goes to the mysitename folder like it should.

Can anyone offer advice on correcting this?

Thanks
David

Samizdata

4:22 am on Nov 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I haven't done this stuff lately, but I think you need an alias:

ServerName www.example.com
ServerAlias example.com

If you want to use other subdomains then a wildcard should work:

ServerName www.example.com
ServerAlias example.com *.example.com

Hope this helps.

...

rothdavid

12:48 pm on Nov 28, 2008 (gmt 0)

10+ Year Member



that helped perfectly ! your example fixed the issue. Thanks much !