开发者

Showing no_picture.png instead of 404 error with condition

开发者 https://www.devze.com 2023-02-04 09:16 出处:网络
I use this code to show no_picture.png for request that returns 404 error: RewriteEngine On RewriteCond %{REQUEST_URI} \\.(jpg|gif|png)$ [NC]

I use this code to show no_picture.png for request that returns 404 error:

RewriteEngine On
RewriteCond %{REQUEST_URI} \.(jpg|gif|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ no_picture.png [L]

I want to write a redirect condition. If user enter /21lls21s1_mini.png then it should be r开发者_开发问答edirect to mini_no_picture.png if user enter /21lls21s1.png then it should redirect to no_picture.png like above. How can i done this ? (21lls21s1 represents file name that doesn't exists)


I'm not sure that I've understood perfectly your question, but you cannot simply add another rule like

RewriteCond %{REQUEST_URI} .*_mini_\.(jpg|gif|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ mini_no_picture.png [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消