【问题标题】:Apache rewrite rule for error page in httpd.confhttpd.conf 中错误页面的 Apache 重写规则
【发布时间】:2020-10-20 06:44:46
【问题描述】:

如果用户代理是 Mozilla firefox,我必须在 httpd.conf 中编写一个重写规则来显示错误代码。我试过这个规则

<VirtualHost *:8004>
SSLEngine on
RewriteEngine on
RewriteCond "{HTTPD_USER_AGENT}" "^Mozilla/5.*"
RewriteRule ^/?page\.html$ - [R=404]
</VirtualHost>

我可以重启apache,但通过firefox访问时没有显示错误页面。

【问题讨论】:

    标签: httpd.conf


    【解决方案1】:

    不清楚您在测试期间遇到了什么错误,但请尝试类似的方法

    RewriteCond %{HTTP_USER_AGENT} ^Mozilla [NC]
    RewriteRule .* - [F,L]
    

    如果你想要一个自定义的 404 页面,配置一个合适的 ErrorDocument

    ErrorDocument 404 /var/www/ErrorPages/404.php 
    

    【讨论】:

      猜你喜欢
      • 2014-02-01
      • 2014-09-01
      • 2012-04-20
      • 2012-10-08
      • 2012-01-05
      • 1970-01-01
      • 2011-09-02
      • 2011-10-26
      • 1970-01-01
      相关资源
      最近更新 更多