Lukas Dr.
Lukas Dr.

Reputation: 13

Apache2 custom 404 Page won't load (.htaccess)

i want to create a custom errorpage for my small webserver which runs on apache2 on raspbian. But sadly the created page isn't loaded by a browser in case of an URL which can't be resolved ... the browser just prints the path to the created errorpage on the upper left-hand corner.

html of the custom page so far:

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

html of the loaded page:

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

My .htaccess-file, which is placed in /var/www/

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

Location of my errorsites-dir with custom errorsites: /var/www/sites/

(Of course I set "AllowOverride" in the default-file in /etc/apache2/sites-available to "all".)

Thanks for the help

Lukas

Edit: default-file of 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

Upvotes: 1

Views: 250

Answers (1)

Honore Doktorr
Honore Doktorr

Reputation: 1625

From the ErrorDocument docs:

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 does not begin w/ a slash and so is treated as a message to be displayed. Changing it to /sites/errorsites/404.html should fix, if sites is relative to your DocumentRoot…

Upvotes: 1

Related Questions