I just enabled Clean URLs on my site (because its required by imagecache). On some pages, my header images disappear. Compare www.rockrapidsia.com to http://www.rockrapidsia.com/node/229 to see the difference. I can disabled clean URLs, but that causes other problems.

Comments

arh1’s picture

taking a quick look, at least some of your problem doesn't have to do w/ clean URLs at all. many of your images use relative file paths that will break at locations other than your front page.

for example, within div#site-logo you have an image with a path of "themes/rockrapids/images/site-logo.png". at http://www.rockrapidsia.com/ , the image will be correctly found at http://www.rockrapidsia.com/themes/rockrapids/images/site-logo.png , but at http://www.rockrapidsia.com/node/229 the browser will look for the image at http://www.rockrapidsia.com/node/themes/rockrapids/images/site-logo.png , and it won't be found.

to work around that, use root relative paths to images in your theme and content: e.g. "/themes/rockrapids/images/site-logo.png" (starting with the slash) rather than "themes/rockrapids/images/site-logo.png". for your theme, you can also look into Drupal functions like base_path and path_to_theme.

hth!

cog.rusty’s picture

On the other hand, when you are not using clean URLs you are always on the front page URL and the rest are arguments (http://example.com/?q=something), so the problem does not appear.

So, to be fully covered for clean URLs:
For theme files, use base_path() . path_to_theme() . '/' . $filename
For uploaded files,
- in php code you can use base_path() . file_directory_path() . '/' . $filename
- in links in your content you need to specify an absolute URL path with a front slash, including Drupal's installation URL path if there is one in the base URL of your site. (This can be an inconvenience when you want to move the site elsewhere.)

LuisCypher’s picture

I am new to Drupal and have spent the last 3 days trying to figure a lot of stuff out, there is a lot to learn.
Some of the workings of Drupal can be counter intuitive or just different to what a novice user would expect to be a standard practice when dealing with web pages.
I am attempting to set up my site for portability and I just tried to add an image to a post, you just saved me a lot of time and frustration.

Thankyou

akki123’s picture

to work around that, use root relative paths to images in your theme and content: e.g. "/themes/rockrapids/images/site-logo.png" (starting with the slash) rather than "themes/rockrapids/images/site-logo.png".

This solution only works, if drupal installation is in root directory.

Is there any way to fix this path in content html with out using PHP code?

Though I can fix this with

global $base_path; // added after edit 

Only local images are allowed.

echo $base_path;

sites/default/files/images/stories/content_img/cmpct.jpg" />

in content item but I want some solution with out using php

akki