开发者

Technique for setting images path?

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开发者_C百科 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜