【问题标题】:Prevent .php extension in htaccess file防止 htaccess 文件中的 .php 扩展名
【发布时间】:2018-07-25 09:38:11
【问题描述】:

我的一个客户的网站在网址后被大量指向“van.php”的有毒链接所击中。

我要做的是将扩展名为 .php 的任何内容重定向到 404 页面。

例如

  • domain.com/index.php
  • domain.com/van.php
  • domain.com/anything.php

这可能吗,如果可以,怎么办?

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    将此代码放入您的DOCUMENT_ROOT/.htaccess 文件中:

    ErrorDocument 404 /404.php
    
    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[/\s?] [NC]
    RewriteRule ^ - [R=404,L]
    

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 1970-01-01
      • 1970-01-01
      • 2012-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多