Here is my problem:

I have copied a web site onto my development server.

All the images and files are called using absolute paths, for example:
<img src="/images/picture.jpg" />

So it's trying to do this: http://www.localhost.com/images/pictures.jpg
When I want it is actually suppose to do this: http://www.localhost.com/client/folder/images/pictures.jpg

How do I fix this?

Thanks to anyone who reads this.

Recommended Answers

All 5 Replies

if you using dreamweaver there is an option to change from absolute path to relative paths.

As you have posted this in the php section. I am guessing you want a php solution for it. I did a bit of searching and found a php script which can search and replace a piece of text at


I have not tried it so you gotta read the code and give it a shot. Let me know how it turns out.

Member Avatar

Hi zer0cool,

<img src="/images/picture.jpg" /> is a relative link (it is relative to the location of the doccument that contains it), not an absolute link.

If you copy the directory structure to the developement server, you shouldn't need to change any links if they are all relative. Of course, this would mean placing all of this clients website files on the root of your dev server though.

Hope this helps.

I hate to correct someone in Public but Zagga is wrong.
<img src="/images/picture.jpg" /> is not based on the current directory but on the Document Root directory for the web site. For example all the sites on my server are located in /var/www/html/ and have their own directory by domain. My web site resides in /var/www/html/txlinux.com/ which is listed as the document root for the site I can refer to any file in the top directory of the site with <img src="/picture.jpg" /> but the absolute path for the files on the server is /var/ww/html/txlinux.com/picture.jpg. The only time I really need to use this form of the path is when using "Include file.php (i.e. Include /var/www/html/txlinux.com/config/config.php )

"./" is the current directory and "../" is one directory up.

commented: well done +1
Member Avatar

If I am wrong, I am glad people are willing to correct me, or I would never learn :)

What I was trying to do though was point out the difference between an absolute URL (http://www.mysite.com/images/smile.gif) and a relative URL (images/smile.gif).

The example I used (<img src="/images/picture.jpg" />) is not an absolute URL (because it is not the full, unique address to the file) but it does act like one because the first "/" is an instruction to start at the server root, no matter where the current document is.

This doesn't help zer0cool with their problem though.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.