Mod Rewrites不会转到"404页面未找到".对于不存在的页面 [英] Mod Rewrites won't go to "404 page not found" for non existing pages

查看:85
本文介绍了Mod Rewrites不会转到"404页面未找到".对于不存在的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下非常有效的代码:

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]

我的问题是,当我转到网站上不存在的页面时. mysite.com/books我收到以下警告错误:无法打开流:没有这样的文件或目录.有没有办法避免此错误,而是转至找不到404页"?

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?

推荐答案

您无法使用Apache的mod_rewrite处理它,这是一个脚本错误,必须由代码(在您的情况下为php)来处理.

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.

这篇关于Mod Rewrites不会转到"404页面未找到".对于不存在的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆