I having some problems with displaying some images (in blocks) on my site while using 'clean URLs'.
The site itself is working well (with clean URLs on or off). All 'top level' pages, including adds, blocks, nodes, taxonomy images, etc work as expected. The problem exists when I try to go to a 'deaper' level.
Example. I have created pages like: http://www.example.com/about with some related images in blocks in the side columns... ( I have set these block to only display on related pages by putting about* in the space provided after selecting the 'display only on listed pages' option in the relevant block configuration page).
The blocks contain code like this: <center><img src="files/about/myphoto.jpg"></center> (image files have been uploaded to the server and permissions checked, etc)
All of this works exactly as it should until I go to a deaper level.
Let's say i create a page (node/56 ... or whatever) and create an alias node/56 >> about/myjob When I surf to http://www.example.com/about/myjob everything works fine (clean URLs work)... except the blocks on the sides of the page: the are empty (in Firefox) or show the little red X (IE) .
Clicking on the 'properties' of the image (IE) shows that the browser is looking in http://www.example.com/about/myjob/files/about/myphoto.jpg and NOT in http://www.example.com/files/about/myphoto.jpg where it should be looking... so it is using a 'relative path' from the current node.
When I turn clean URL's off, everything works perfectly. All 'block' images are displayed where and when they should be.
I've been working on this for hours and have searched google, drupal.org, apache.org... I have also checked and rechecked my apache settings and my .htaccess file etc....
I know I can get around this by using a full URL (FQDN) with each image but this is a development site (developed offline) and will be moving to a new domain when complete. Besides, I prefer to use relative paths where possible.
I'm using Ubuntu 7.10, Apache 2.2, Mysql 5.0.45, drupal 5.7
Any ideas?
Comments
Maybe...
I could be wrong here, but in my experience, adding a "/" at the beginning of the url (
<center><img src="/files/about/myphoto.jpg"></center>) seems to make this work.How!??
Would you mind explaining how the hell you know or came up with that solution? It worked! I've been trying to fix that for a while now and just like that? add a /??
Anyway, Thanks a lot you rock!
Web Browser Voodoo
the "/" tells the web browser to start from the root of the site, so for urls like "http://mycoolsite.com/node/3" the "/" says "Start at the part after "http://mycoolsite.com" when linking to this image.
That did the trick!
This did the trick for me also! Thanks a bunch!
By the way, I was able to change several hundred references from
src="files/tosrc="/files/in a a few seconds using the Search & Replace Scanner module at http://drupal.org/project/scanner