views:

31

answers:

2

Hello

Example:

<img src="/images/name.jpg" alt="" />

This is what I want:

<img src="name.jpg" alt="" />

Upon request for the image, the image will not be found because it is in the "images" directory and not in the root where the HTML file is.

Is there a way htaccess or any other technique will be able to recognise the http image request and rewrite it with the the path (/images/) prepended?

For example when htaccess reads the extension (.jpg) can it say something like

Hey .jpg you're an image, let's prepend the images path and send you back to the client

Thanks in advance!

A: 

Could it be done with Php?

DADU
A: 

This is possible, but not a good idea. By rewriting all incoming requests for images to a certain location, you will be reducing the number of possible folders in which you can store images on your server to one.

The better idea is to always use a correct path - even an absolute path like the one you are showing.

Pekka