des*_*ing 4 header http http-status-code-404
我有一个问题我遇到了麻烦:/ err404页面的200OK标题状态问题,虽然它应该是404标题.200好有什么问题?真有可能200 OK应该在404错误页面标题状态?
感谢建议!! 非常感谢!
我想它与.htaccess有关.这是我的.htaccess文件;
ErrorDocument 404 /err404.html
RewriteEngine On
RewriteRule ^login.html$ index.php?s=login&a=loginDo [QSA,L]
RewriteRule ^logout.html$ index.php?s=login&a=logoutDo [QSA,L]
RewriteRule ^([^/]*).html$ index.php?s=$1 [QSA,L]
RewriteRule ^members/([^/]*)$ index.php?s=profile&username=$1 [QSA,L]
RewriteRule ^([^/]*)/$ index.php?s=listing&search[cityString]=$1 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/$ index.php?s=listing&search[neighborhoodString]=$2 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*).html$ index.php?s=details&seo_friendly=$3 [QSA,L]
Run Code Online (Sandbox Code Playgroud)
我也有一些与此htaccess文件相关的麻烦:(
问题1; 当url像http://localhost/fdfcdcvdvdvbdf.html(不存在url)时,它会重定向到主页,但它应该重定向到err404.html.对这个问题有什么看法吗?对于像http://localhost/fdfcdcvdvdvbdf.ht或http:// localhost/fdfcdcvdvdv这样的url,err404重定向效果很好
问题2; 如何解决这个200 OK问题:/
Pet*_*ell 20
404值不仅仅是圣诞树装饰 - 它传达了有关网址的真实信息,即它不存在.发送描述页面不存在这一事实的200页是完全不同的事情,特别是对于程序而言,与人类相反.
通过返回200 OK丢失页面的状态,您可能会混淆浏览器(如果您没有自定义错误HTML可能不会显示错误消息)和搜索引擎(他们会开始索引任何人告诉他们的内容,例如example.com/this-web上门-是,可怕的-使用-我们-竞争对手)...
关于你对mod_rewrite的编辑:
http://example.com/lsdjkldsjlk.html匹配你的第三个RewriteRule,所以它将重定向到index.php.
index.php脚本是您应该检测到没有与s参数相关的内容并通过调用返回404状态的位置header().