Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
778 views
in Technique[技术] by (71.8m points)

.htaccess to redirect images

i'm still new to the redirectrule thing from htaccess and have successfully redirected my pages so that the pretty URL shows up, but is there a way to redirect the images so that it is not relative? Is there a way or function that allows me to redirect images without changing it one by one ?

Like i after redirecting the page, i get relative URL, hence my images are showing something extra in their links.

so this is the actual url to the image

http://www.yousite.com/page/images/this.jpg

but i'm getting stuff like

http://www.yoursite.com/images/page/images/this.jpg
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I am not sure this will solve the problem, but instead of modifying all the links you could use the BASE element in each page to define a base URI:

From http://www.w3.org/TR/html4/struct/links.html#h-12.4:

When present, the BASE element must appear in the HEAD section of an HTML document, before any element that refers to an external source. The path information specified by the BASE element only affects URIs in the document where the element appears.

Examples:

 <HEAD>
   <BASE href="ImagesBasePath">
 </HEAD>

Or just:

 <HEAD>
   <BASE href="/">
 </HEAD>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...