图片的RewriteRule [英] RewriteRule for images
本文介绍了图片的RewriteRule的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须在我的网站上重写一些URL.我将其放在htaccess中进行更改: http://example.com/john/?a=1&b=2-> http://example.com/index. php?account = john& a = 1& b = 2
I have to rewrite some url on my site. I've put this in my htaccess to make this change: http://example.com/john/?a=1&b=2 --> http://example.com/index.php?account=john&a=1&b=2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/?$ ./index.php?account=$1 [NC,QSA,L]
现在,我必须以这种方式重写图像url.具有此路径的每个图像: example.com/john/images/a.jpg
Now I have to rewrite images url in this way. Every image with this path: example.com/john/images/a.jpg
应指向物理路径: example.com/accounts/john/images/a.jpg
我该怎么做?
注意:约翰"不是固定的,但可以是所有可能的单词.
Note: "John" is not fixed but can be every possible word.
推荐答案
您可以尝试以下脚本:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?account=$1 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/images/([^/]+).jpg$ /accounts/$1/images/$2.jpg [NC,L]
这篇关于图片的RewriteRule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文