Skip to main content
lovewebdev
Inspiring
May 9, 2010
Question

root url's don't work in coldfusion \images\pic.jpg?

  • May 9, 2010
  • 2 replies
  • 2853 views

I want to be able to use a url like

\images\pic.jpg

on any page so that it maps correctly to the image withiut using the domain name in the url like http://www.domain.com\images\pic.jpg

This doesn't seem to work in CF. What am I missing?

This topic has been closed for replies.

2 replies

Inspiring
May 9, 2010

CF doesn't handle the serving of images (or, for that matter, any sort of file), your web server does.

But slashes in URLs should be forward slashes, not back slashes.  That could be what your problem is.

--

Adam

lovewebdev
Inspiring
May 9, 2010

Thanks guys I think I miscommunicated. That is the code. basically I have something like this in my css

#lb
     {
     background-image:url(/images/divbg/l.gif);
     }

the image isn't coming up unless I make it relative. I would like to use the / prefix so i won't have to specify the relativeness.

ilssac
Inspiring
May 9, 2010

I always have trouble with CSS image urls.  What works for me is to find the URL that works in the browser.  I.E. "http://www.localhost/images/css/background/monkey.jpg".  I put that into my browser to make sure that it can be requested by the browser.  Then I just strip off the domain name, and put the rest into the CSS statement.  I.E. "/images/css/background/monkey.jpg"

ilssac
Inspiring
May 9, 2010

You are going to have to provide some code for this, if you would like us to help.

By default, ColdFusion is not going to be involved in the serving of the response to an image request.  So that url should be a fine root relative url.  Other then that your directory delimiter (\) is backwards, which some web servers complain about.  But that is rather rare.