【问题标题】:Redirecting a specific file to the 404 page with htaccess使用 htaccess 将特定文件重定向到 404 页面
【发布时间】:2016-05-05 05:32:34
【问题描述】:

我有一个位于 Web 服务器上的文件(长话短说),在本例中名为“secretFile.sh”。如果用户碰巧知道此文件存在于mysite.com/secretFile.sh,我需要使用 htaccess 将该文件 url 重定向到我的 404 页面。

【问题讨论】:

    标签: .htaccess redirect http-status-code-404


    【解决方案1】:

    您可以在站点根目录 .htaccess 中使用此规则:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} /secretFile\.sh[?/\s] [NC]
    RewriteRule ^ - [R=404,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-05
      • 1970-01-01
      • 2017-08-16
      相关资源
      最近更新 更多