图片的RewriteRule

编程入门 行业动态 更新时间:2024-10-25 16:24:14
本文介绍了图片的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

本文发布于:2023-11-01 18:42:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550102.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图片   RewriteRule

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!