htaccess的重定向图像 [英] .htaccess to redirect images

查看:236
本文介绍了htaccess的重定向图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还是新来的的htaccess的redirectrule的事情,已经成功地重定向我的网页,这样的pretty的URL显示出来,但有没有办法来重定向图像,以便它是不是亲戚?有没有可以让我重定向图像,而无需一个改变是一个方法或函数?

就像我重定向页面后,我得到相对URL,因此我的照片都出现在他们的链接额外的事情。

,所以这是实际的URL到图像

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

但我得到的东西,如

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

解决方案

我不知道这会解决这个问题,但不是改变所有的链接,你可以使用 BASE 元素中的每一页定义一个基础URI:

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

  

在present,BASE元素必须出现在的HEAD部分   HTML文档,引用外部源的任何元素之前。该   由基本元素指定路径信息,只影响的URI   该元素出现的文件。

例如:

 < HEAD>
   < BASE HREF =ImagesBasePath>
 < / HEAD>
 

或者只是:

 < HEAD>
   < BASE HREF =/>
 < / HEAD>
 

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

解决方案

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>

这篇关于htaccess的重定向图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆