Mod Rewrites won't go to “404 page not found” for non existing pages

你说的曾经没有我的故事 提交于 2019-12-25 18:57:11

问题


I have the following code which works great:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?mode=$1 [QSA]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?mode=$1&productContent=$2 [QSA]

My problem is when I go to a page that doesn't exist on my site ie. mysite.com/books I get the following warning error: failed to open stream: No such file or directory. Is there a way to avoid this error and have it go to "404 Page Not Found" instead?


回答1:


You can't handle that with Apache's mod_rewrite, it's a script error and has to be taken care of by the code, php in your case.



来源:https://stackoverflow.com/questions/15396454/mod-rewrites-wont-go-to-404-page-not-found-for-non-existing-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!