简体   繁体   English

当用户请求index.php / blahblahblah时,显示“找不到页面”

[英]Show “page not found” when user requests index.php/blahblahblah

I have the following files in apache server: 我在apache服务器中有以下文件:

pageNotFound.php
index.php
style.css
login.php

I have edited httpd.conf so if user types an address like localhost/wrongpage.php apache shows localhost/pageNotFound.php. 我已经编辑了httpd.conf,因此,如果用户键入的地址类似localhost / wrongpage.php,则apache将显示localhost / pageNotFound.php。 My problem is that when a user types localhost/index.php/blablaitypewhateveriwant or even localhost/index.php/, page index.php comes up with an awful appearence (no css or javascript enabled). 我的问题是,当用户键入localhost / index.php / blablaitypewhateveriwant或什至localhost / index.php /时,页面index.php都会出现可怕的外观(未启用css或javascript)。 So i want to restrict access cases like these and show pageNotFound.php 所以我想限制这样的访问情况并显示pageNotFound.php

edit: To make things easier visit those links to see the difference: http://www.developphp.com/donate.php , http://www.developphp.com/donate.php/blahblah 编辑:为了使事情变得更容易,请访问那些链接以查看不同之处: http : //www.developphp.com/donate.php,http : //www.developphp.com/donate.php/blahblah

您可以修改.htaccess

ERRORDOCUMENT 404 /pageNotFound.php

Following your edit. 按照您的编辑。 You requested page is not a 404. But in your developer tool you can read : 您请求的页面不是404。但是在开发人员工具中,您可以阅读:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://www.developphp.com/donate.php/style/layout_001.css". [...] [...]

You can solve this problem by changing all your css/javascript include by adding slashes. 您可以通过添加所有斜线来更改所有CSS / JavaScript来解决此问题。 For instance : 例如 :

style/layout_001.css to /style/layout_001.css style/layout_001.css/style/layout_001.css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM