htaccess用图像重写子目录(htaccess to rewrite subdirectory with image)

编程入门 行业动态 更新时间:2024-10-22 14:36:43
htaccess用图像重写子目录(htaccess to rewrite subdirectory with image)

对于一个新的爱好网站,我直接调用子目录时遇到问题。

当您转到http://www.placewomen.com/222/222/image.jpg时 ,图像会直接加载。 但是当你转到http://www.placewomen.com/222/222/我有一个提交错误,因为没有index.html / php来显示图像(我也不想要那里......! )。

我想要发生的是当调用子目录时,页面显示为image.jpg。 子文件夹是动态生成的。

我自己是一名前端开发人员,通过htaccess实现这一目标的知识对我来说是“有点”......

任何帮助都非常感谢! 问候克里斯

For a new, hobby, website I have a problem when a subdirectory is called directly.

When you goto http://www.placewomen.com/222/222/image.jpg the image is loaded directly. But when you goto http://www.placewomen.com/222/222/ I've got a premission error because there is no index.html/php to show image (which I also don't want there...!).

What I would like to happen is when subdirectory is called the page is shown with the image.jpg. The subfolders are generated dynamicaly.

I'm a frontend developer myself and the knowledge to make this happen through the htaccess is "a bit" to much for me....

Any help is highly appreciated! greetings Chris

最满意答案

尝试将此添加到文档根目录中的htaccess文件:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME}/image.jpg -f RewriteRule ^(.*)$ /$1/image.jpg [L]

Try adding this to the htaccess file in your document root:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME}/image.jpg -f RewriteRule ^(.*)$ /$1/image.jpg [L]

更多推荐

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

发布评论

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

>www.elefans.com

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