【问题标题】:htaccess to block the 'No input file specified.' messagehtaccess 阻止“未指定输入文件”。信息
【发布时间】:2013-09-07 08:01:26
【问题描述】:

我有一个结构如下的网站: domain.com/directory/subdirectory/index.php

我注意到,当我调用例如:domain.com/directory/subdirectory/index.php/example(最后是 /example)时,我看到消息“未指定输入文件” .'

我还注意到,当我调用时:domain.com/directory/subdirectory/index.php/ 或 domain.com/directory/subdirectory/index.php//(最后是斜线)我看不到消息,页面已加载但没有 css!

我的问题是,有可能用 htaccess 阻止所有这些错误的请求吗?

PS:我使用 Godaddy 共享主机,并且我有一个带有 seo 链接的 .htaccess,例如:

RewriteRule ^index$ index.php [L]
ErrorDocument 404 /404.php

【问题讨论】:

    标签: php regex apache .htaccess mod-rewrite


    【解决方案1】:

    将此规则添加到所有其他规则之上,以阻止所有 URI,例如 /directory/subdirectory/index.php/foo

    RewriteRule (^|/)index\.php.+$ - [L,NC,R=404]
    

    【讨论】:

    • 哇,谢谢!有一种方法可以将它与所有文件一起使用,而不仅仅是在 index.php 上? (例如:contactus.php、faq.php、..)
    • 是的,这是正确的:RewriteRule ^(.*)\.php.+$ - [L,NC,R=404]
    猜你喜欢
    • 2010-12-06
    • 1970-01-01
    • 2012-10-02
    • 2013-01-11
    • 2013-04-08
    • 1970-01-01
    • 1970-01-01
    • 2017-07-24
    相关资源
    最近更新 更多