簡體   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