本文介绍了图片的RewriteRule的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须在我的网站上重写一些URL.我将其放在htaccess中进行更改: example/john/?a=1&b=2-> example/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: example/john/?a=1&b=2 --> example/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/john/images/a.jpg
Now I have to rewrite images url in this way. Every image with this path: example/john/images/a.jpg
应指向物理路径: example/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
发布评论