【问题标题】:Apache2 custom 404 Page won't load (.htaccess)Apache2 自定义 404 页面无法加载(.htaccess)
【发布时间】:2015-07-16 23:55:21
【问题描述】:

我想为我的小型网络服务器创建一个自定义错误页面,该服务器在 raspbian 上的 apache2 上运行。但遗憾的是,如果 URL 无法解析,浏览器不会加载创建的页面……浏览器只会在左上角打印创建的错误页面的路径。

到目前为止的自定义页面的html:

<!DOCTYPE html><html><head></head><body><p>Nooooot found ...</p></body></html>

加载页面的html:

<html><head></head><body>sites/errorsites/404.html</bod></html>

我的 .htaccess 文件,位于 /var/www/

Options -Indexes
ErrorDocument 404 sites/errorsites/404.html

带有自定义错误站点的错误站点目录的位置:/var/www/sites/

(当然我在 /etc/apache2/sites-available 的默认文件中将“AllowOverride”设置为“all”。)

感谢您的帮助

卢卡斯

编辑: apache的默认文件:

ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

【问题讨论】:

    标签: html apache .htaccess apache2


    【解决方案1】:

    来自ErrorDocument docs

    对于本地网络路径(相对于 DocumentRoot),或者是客户端可以解析的完整 URL。 或者,可以提供一条消息以由 浏览器。

    sites/errorsites/404.html 不以斜线开头,因此被视为要显示的消息。将其更改为 /sites/errorsites/404.html 应该可以解决,如果 sites 与您的 DocumentRoot 相关...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      • 2019-03-13
      • 2017-05-25
      • 1970-01-01
      • 2014-04-02
      • 2015-01-26
      相关资源
      最近更新 更多