繁体   English   中英

php htaccess重定向404错误页面

[英]php htaccess redirect 404 error page

我正在构建一个LAMP应用程序www.testing.com并且有一个图像URL www.testing.com/image/folderA/a.jpg

我希望在.htacess中有一个重写规则,以便如果用户导航到/ image / foldera中不存在的图像,则他将被重定向到另一个具有URL www.testing.com/image/folderB/b.jpg图像。

这是我的代码。

RewriteRule ^image/folderA/(.*\.(jpg|gif|png))$ http://%{SERVER_NAME}/image/folderB/b.jpg [R=404,L]

但是,这不起作用,因为应该返回图像的www.testing.com/image/folderA/a.jpg给出404。为什么?

使用R标志时,请注意以下几点:

However, if a status code is outside the redirect range (300-399) then the substitution string is dropped entirely, and rewriting is stopped as if the L were used.

http://httpd.apache.org/docs/trunk/rewrite/flags.html#flag_r

这意味着您的重写规则将删除替换字符串,并将所有请求重定向到指定的文件到内置404页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM