changing *:80 to specific url causes files not to be read

Discussion in 'Apache' started by nigeldodd, May 19, 2016.

  1. #1
    If I change the top line of the site.conf file from
    <VirtualHost *:80>
    to
    <VirtualHost www.sitename.co.uk:80>
    the site renders without reading the .css file or any other file in a subdirectory. Looking at the access.log file I get the following
    80.195.213.xxx - - [19/May/2016:18:54:31 +0000] "GET /themes/garland/style.css HTTP/1.1" 404 534
    when <VirtualHost www.sitename.co.uk:80> is used but
    80.195.213.xxx - - [19/May/2016:19:06:42 +0000] "GET /themes/garland/style.css HTTP/1.1" 200 4470
    when <VirtualHost *:80> is used.

    Why, when I use a specific site url does apache 2.4 fail to read the sub directories?
     
    nigeldodd, May 19, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    I can't find anywhere were they talk about this type of setup - are you sure it's valid to use a domain in the VirtualHost declaration? Only thing I can find are *, IP, _default_ - no domain. And why would you want to anyway?
     
    PoPSiCLe, May 19, 2016 IP
  3. nigeldodd

    nigeldodd Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    There is an example here https://httpd.apache.org/docs/current/vhosts/examples.html
    where it gives an example (sorry the formatting is messed up)
    Listen 80

    # This is the "main" server running on 172.20.30.40ServerName server.example.comDocumentRoot"/www/mainserver"

    <VirtualHost172.20.30.50>
    DocumentRoot"/www/example1"
    ServerName www.example.com
    # Other directives here ...
    </VirtualHost>
     
    nigeldodd, May 19, 2016 IP
  4. nigeldodd

    nigeldodd Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    Actually you are right, there are no url's in this part, just IP addresses.

    thanks for making me read the example again. I was actually trying to get one virtual host for both www.example.com and example.com.
     
    nigeldodd, May 19, 2016 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    If you need one virtual host for both with and without www. just make a ServerAlias in the VirtualHost?
     
    PoPSiCLe, May 19, 2016 IP
  6. nigeldodd

    nigeldodd Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Thanks, I shall have to look up how that is done.
     
    nigeldodd, May 20, 2016 IP