如何使用htaccess的改变图像路径? [英] How to use htaccess to change image paths?
问题描述
我有一个HTML文件,有一个形象:
< IMG SRC =../笑脸/ happy.gif/>
是否有可能这个路径重定向到另一个使用的.htaccess
?
所以上面的例子将成为相当于
< IMG SRC =http://static.example.com/smilies/happy.gif/>
那么,你可能会逃脱重定向与 /smilies/happy.gif
来结束所有通话该目录中,所以它不会不管哪里打来。这并不意味着你应该不希望把这种其他一些subedirectory,但我想你不知道。
是这样的(猜测这里,水湿测试,所以阅读起来就rwriting有:)
重写规则^(。*)/图像/$(.*)http://static.example.com/smilies/$2 [L,R = 301]
基本上你正在改写一切,在它/图片/,以静态联系地址,粘贴无论是新asdress(在$ 2啄)后的图像,然后表示这是最后一个命令解析后(停奇怪的事情在htaccess的),并且你想有一个301(永久移动)code发送。
I have a html file that has an image:
<img src="../smilies/happy.gif" />
Is it possible to redirect this path to another using .htaccess
?
So the above example would become equivalent to
<img src="http://static.example.com/smilies/happy.gif" />
Well, you might get away with redirecting all calls that end with /smilies/happy.gif
to that directory, so it wouldn't matter where the call came from. That does mean you should not wish to call this to some other subedirectory, but I imagine you don't.
something like this (guessing here, cann't test, so read up on the rwriting there :)
RewriteRule ^(.*)/images/$(.*) http://static.example.com/smilies/$2 [L,R=301]
basically you are rewriting everything that has '/images/' in it to that static adress, pasting whatever was after images after the new asdress (the $2 thingy) and then indicating that this is the last command to parse (to stop strange things in the htaccess) and that you want a 301 (permanently moved) code to be sent.
这篇关于如何使用htaccess的改变图像路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!