【问题标题】:Symfony - Use Apache ErrorDocumentSymfony - 使用 Apache 错误文档
【发布时间】:2018-03-16 14:40:05
【问题描述】:

我想用 apache ErrorDocument 替换 symfony 的错误模板。

我有以下配置:

<VirtualHost *:80>

ServerName localhost-de
ServerAdmin me@mydomain.com
DocumentRoot /var/www/html

<Directory /var/www/html/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All 
  ErrorDocument 404 /staticErrorPage.html
  Order deny,allow
  Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /kontakt "/var/www/html/contact/web"
Alias /skin "/var/www/html/skin"

RewriteEngine on

RewriteRule ^/skin/(.{7})/(.*) /skin/$2

SetEnv locale de_DE
</VirtualHost>

我的 Symfony 应用程序位于“/var/www/html/contact/”下。当我输入像“localhost-de/foo”这样的不存在页面时,我正在获取我的 html 页面的内容。 但是当我进入一个不存在的页面时,比如“localhost-de/kontakt/foo”,我总是得到 symfony/twig 页面的内容。

我知道我可以覆盖 twig 模板,但我不想这样。任何想法如何处理这个?

【问题讨论】:

    标签: apache symfony errordocument


    【解决方案1】:

    ErrorDocument 仅用于您指定的目录。您应该将 ErrorDocument 包含在 Location 或 LocationMatch 指令中。阅读 apache 文档了解更多详情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多