Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Running virtual hosts on Mac OS X 10.6.8 running Apache 2.2.22.

/etc/hosts is as follows:

127.0.0.1       localhost     3dweergave   studio-12.fritz.box
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0     localhost

Virtual hosts configuration:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/opt/local/www/3dweergave"
    ServerName 3dweergave
    ErrorLog "logs/3dweergave-error_log"
    CustomLog "logs/3dweergave-access_log" common
    <Directory "/opt/local/www/3dweergave">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName main
</VirtualHost>

This will output the following settings:

*:80 is a NameVirtualHost
default server 3dweergave (/opt/local/apache2/conf/extra/httpd-vhosts.conf:21)
port 80 namevhost 3dweergave (/opt/local/apache2/conf/extra/httpd-vhosts.conf:21)
port 80 namevhost main (/opt/local/apache2/conf/extra/httpd-vhosts.conf:34)

I made 3dweergave the default server by putting it first in the list. This will cause all undefined virtual hosts' names to load 3dweergave, and thus http://localhost will point to 3dweergave. Of course, normally, the first in the list is the virtual host main and localhost will point to main, but for testing purposes I switched them.

When I navigate to http://localhost, my CakePHP default homepage shows as expected: Screenshot 1

But when I navigate to http://3dweergave, my CakePHP default homepage doesn't show as expected. It looks like every relative link to resources are not accepted by the server: Screenshot 2

For example, the CSS isn't loaded. When I open the source and click on the link, it opens the CSS file in the browser without errors. But when I run FireBug while loading the webpage, it seems that the CSS file isn't retrieved. (<link rel="stylesheet" type="text/css" href="/css/cake.generic.css" />)

How can I fix this unwanted behavior?

share|improve this question
Take a look at Apache's log to see if the files are requested or not. Maybe Apache is serving them with an incorrect content_type, in which case it will not be applied by some browsers. – The Disintegrator Oct 31 '12 at 4:40
If you ping http:// 3dweergave does it resolve to your server's IP? – AWinter Oct 31 '12 at 8:01
@AWinter output of ping 3dweergave is PING localhost (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.039 ms – Christian Stadegaart Oct 31 '12 at 15:09
@TheDisintegrator - output log when accessing http://3dweergave: access log. Output log when accessing http://localhost: access log. LogLevel in httpd.conf is set to debug. The error log doesn't show any errors. – Christian Stadegaart Oct 31 '12 at 15:26
And what about the response headers? – The Disintegrator Nov 1 '12 at 3:14
show 1 more comment

1 Answer

Take a VERY close look at the source code generated in both cases, look for differences. The request for bake-banner in 3dweergave gets a 301 to /bake-banner/ while in localhost it's directly to /bake-banner/

At 3dweergave The browser is requesting only one image /img/banners/CakeFest2012Banner.png... The only image without a dot in it's name...

Missing quotes? Extra spaces?

share|improve this answer
Generated source of http://localhost and Generated source of http://3dweergave. <iframe src="http://cakephp.org/bake-banner" style="overflow:hidden; border:none;" height="160" width="830"> requests both for localhost and 3dweergave http://cakephp.org/bake-banner. CakePHP's server nginx responded differently on both requests. One got redirected, the other didn't. This says nothing about my setup and source code though. – Christian Stadegaart Nov 5 '12 at 9:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.