Forum Moderators: phranque

Message Too Old, No Replies

Problem with localhost urls

         

cantthinkofanickname

7:09 pm on Feb 27, 2009 (gmt 0)

10+ Year Member



I have installed a wamp on my laptop and copied my live site there to allow for testing changes before uploading them. I have configured virtual hosts and the websites show OK. Problem is the css background specified images do not appear on the site so the url is obviously getting "lost" e.g.

the css (this is a background image) url is /images/banners/image.jpg
the site root is /dcmms (I have several sites here so this is the "root" for that one).
If I put "dcmms/" in front in firefox the image appears.
The live site (remote) works and delivers the image to the page OK with the above url. The live site root is (of course) different so I cannot change the background urls.
The HTML image urls work on both sites.
I assume I need some sort of redirect in apache (not in .htaccess then I would need two, one for live site and one for local).

This is a mystery to me and would appreciate some help.

g1smd

7:50 pm on Feb 27, 2009 (gmt 0)

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



Does the URL for your link to the CSS file start with a slash?

If not, add one.

cantthinkofanickname

9:16 pm on Feb 27, 2009 (gmt 0)

10+ Year Member



Yes it does. I assume that this continues from that in the hosts file which is localhost/wamp/www.

jdMorgan

12:42 am on Feb 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the definition (in the server config file) for the DocumentRoot of this site?

In your error log, you will see the filepath (not the URL) for the failed CSS file access. It will be incorrect -- either missing a filepath-part, or with an additional, incorrect filepath-part. What is wrong with it?

By combining the information from both of these questions, it is almost always possible to figure out what is wrong. It is likely that DocuementRoot is incorrect, and that the CSS filepath is therefore being constructed incorrectly from the requested URL-path.

Jim

cantthinkofanickname

8:06 am on Feb 28, 2009 (gmt 0)

10+ Year Member



The document root in the apache config is:

DocumentRoot "c:/wamp/www/"

Other parts that may be relevant are:
Include "c:/wamp/alias/*"
ServerRoot "c:/wamp/bin/apache/apache2.2.10"

Here is the access log where it is the last one which does not appear:

127.0.0.1 - - [26/Feb/2009:08:57:07 +0000] "GET /dcmms/templates/beez/images/reset.gif HTTP/1.1" 304 -
127.0.0.1 - - [26/Feb/2009:08:57:08 +0000] "GET /dcmms/modules/mod_gk_news_image_1/images/load.gif HTTP/1.1" 304 -
127.0.0.1 - - [26/Feb/2009:08:57:08 +0000] "GET /dcmms/components/com_gk2_photoslide/images/thumbm/910507turnball.png HTTP/1.1" 304 -
127.0.0.1 - - [26/Feb/2009:08:57:08 +0000] "GET /dcmms/components/com_gk2_photoslide/images/thumbm/394061londonConcertante.png HTTP/1.1" 304 -
127.0.0.1 - - [26/Feb/2009:08:57:08 +0000] "GET /dcmms/components/com_gk2_photoslide/images/thumbm/891475victoria.png HTTP/1.1" 304 -
127.0.0.1 - - [26/Feb/2009:08:57:08 +0000] "GET /images/banners/dukes2.jpg HTTP/1.1" 404 223
127.0.0.1 - - [26/Feb/2009:08:57:12 +0000] "GET /dcmms/images/banners/dukes2.jpg HTTP/1.1" 304 -

IF I put (in firefox firebug) ../../../ or dcmms/ to the css background path (dukes2.jpg) it works. Not correct images (in the html source) do have the dcmms/ in front of them and do work.

[edited by: cantthinkofanickname at 8:14 am (utc) on Feb. 28, 2009]

cantthinkofanickname

8:09 am on Feb 28, 2009 (gmt 0)

10+ Year Member



Please see reply above, this is an extension. The document root does not seem right as I have many sites below that and I have configured virtual hosts. Thanks.

jdMorgan

1:24 pm on Feb 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post the HTML code and/or CSS directives which include the css background image.

Jim

cantthinkofanickname

2:19 pm on Feb 28, 2009 (gmt 0)

10+ Year Member



.banneritem {layout.css (line 1392)
background:#D6EACC url(/images/banners/dukes2.jpg) no-repeat scroll 0 0;
min-height:100px;
padding:3px;
text-align:center;
width:189px;
}

<div class="banneritem"><p id="banp1">DUKE'S</p>
<p id="banp2">Auctioneers since 1823</p>
.....

As you can see the "dcmms/" has not been added whereas in the html example:

<div id="header">
<h1 id="logo">
<img src="/dcmms/templates/beez/images/dcmmsLogo.png" border="0" alt="DCMMS Logo" />

it has.

jdMorgan

2:31 pm on Feb 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right, so in the virtual host for this site, the DocumentRoot should be specified as "c:/wamp/www/dcmms" and relative links should use use the "home page" directory of the site as their starting point, e.g.

background:#D6EACC url(/images/banners/dukes2.jpg) no-repeat scroll 0 0;
<img src="/templates/beez/images/dcmmsLogo.png" border="0" alt="DCMMS Logo" />

Jim

cantthinkofanickname

3:00 pm on Feb 28, 2009 (gmt 0)

10+ Year Member



OK, thanks. The DocumentRoot in http-vhosts.conf is indeed C:/wamp/www/dcmms.

How and where do the relative links get set?

Funny that the html source works though!