2013-06-12 76 views
0

我正在构建一个LAMP应用程序www.testing.com,我有一个图像url www.testing.com/image/folderA/a.jpgphp htacess重定向404错误页面

我希望在.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任何想法,为什么?

在此先感谢。

回答

0

使用时您需要记住以下的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

这意味着你的重写规则被丢弃substition串并重定向到指定的文件的所有请求到内置的404页面。