Apache2 自定义 404 页面无法加载 (.htaccess)
Apache2 custom 404 Page won't load (.htaccess)
我想为我在 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的default-file中设置"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
URLs can begin with a slash (/) for local web-paths (relative to the
DocumentRoot), or be a full URL which the client can resolve.
Alternatively, a message can be provided to be displayed by the
browser.
sites/errorsites/404.html
不以斜杠开头,因此被视为要显示的消息。将其更改为 /sites/errorsites/404.html
应该可以解决,如果 sites
与您的 DocumentRoot 相关...
我想为我在 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的default-file中设置"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
URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser.
sites/errorsites/404.html
不以斜杠开头,因此被视为要显示的消息。将其更改为 /sites/errorsites/404.html
应该可以解决,如果 sites
与您的 DocumentRoot 相关...