我要重定向
www.domain/images/Apple.jpg
www.domain/images/Apple.jpg
到
to
www .domain / Apple.html
www.domain/Apple.html
这是Live工作示例,这正是我真正想要的 more-sky/data/out/2/IMG_21306 .jpg
Here is the Live working example, This is what i exactly want more-sky/data/out/2/IMG_21306.jpg
如何重定向到其父页面,即( more-sky/WDF-21306.html )
How it redirect to its parent page i.e (more-sky/WDF-21306.html)
推荐答案假设您在Apache中启用了 mod_rewrite :
Assuming you have mod_rewrite enabled in your Apache:
RewriteEngine On RewriteBase / RewriteRule ^images/([^\.]+)\.(jpe?g|png) /$1.html [QSA,L]编辑:如Wh1T3h4Ck5, QSA (查询字符串追加)标志w可能是可选的, L ( Last )也将取决于上下文和其他规则。请阅读有关 RewriteRule标志的信息。
as noticed by Wh1T3h4Ck5, QSA (Query String Append) flag would be optional, as well as L (Last) would depend on the context and other rules present. Please, read about RewriteRule flags for more information.
要澄清一下:此解决方案假定已经有图像名称的HTML文档存在。
To clarify: this solution assumes that an HTML document with the name of the image already exists. Something like:
<html> <head> <title>Apple</title> </head> <body> <img src="images/Apple.jpg" alt="Apple"> </body> </html>对于大量图像而言,这不是最佳解决方案,但似乎适合OP的情况。
This is not an optimal solution for a large number of images, but it seemed to fit OP's case.
更多推荐
.htaccess,如何将任何.jpg页面重定向到其附件页面(HTML)
发布评论