Apache htaccess Custom ErrorDocument not working properly for root home page 403 Error Issue and Solution

So I have a domain "testdomain.com".

Inside test domain.com's root is the following .htaccess:

Options +FollowSymLinks -Indexes
ErrorDocument 403 /launch/index.html

Order Deny,Allow
Deny From All
Allow From

When you visit anything other than root things work fine.  Eg. if you visit http://testdomain.com/somedirfile.html

It will show the right error in /launch/

But if you just visit the root you get the standard Apache Test page even though a 403 is returned.  The reason for this is because of an Alias "Error" in /etc/httpd/httpd.conf

Find this line and comment it out:

Alias /error/ "/var/www/error/"

What happens when visiting root is that it checks for a custom 403 error in /var/www/error/ and when it doesn't find one in there it returns noindex.html (the Apache test page).

However I don't know a better work-around what Apache then does after commenting out that alias is it insists in then looking inside your /www/document_root/error/ folder for a matching custom file.  If not it looks for a noindex.html in there.

So all I did was create a no index.html in an error folder within my document root.

This solves the issue but I am not sure of how to make a better solution.  I searched for hours modifying the vhost configuration but nothing worked or helped except the above.

These URLs below had the same issue:



Here is some of the troubleshooting process I went through:


I have an issue where I am only allowing a few IPs to view a website in .htaccess:

Options +FollowSymLinks -Indexes
ErrorDocument 403 /launch/index.html

Order Deny,Allow
Deny From All
Allow From

# Now it works if you go to http://url/somecrap it will take you to /launch/index.html
But if you just go to the reoot http://url/ or http://url you get the Apache Test page instead:


edit /etc/httpd/httpd.conf

# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html

# Putting this all together, we can internationalize error responses.
# We use Alias to redirect any /error/HTTP_<error>.html.var response to
# our collection of by-error message multi-language collections.  We use
# includes to substitute the appropriate text.
# You can modify the messages' appearance without changing any of the
# default HTTP_<error>.html.var files by adding the line:
#   Alias /error/include/ "/your/include/path/"
# which allows you to create your own set of files by starting with the
# /var/www/error/include/ files and
# copying them to /your/include/path/, even on a per-VirtualHost basis.

#Alias /error/ "/var/www/error/"

[root@serverdev error]# mv noindex.html noindex.html-bad
[root@serverdev error]# readlink -f .

Alias /error/ "/var/www/error/"

#Alias /error/ "/var/www/error/"

<IfModule mod_negotiation.c>
<IfModule mod_include.c>
    <Directory "/var/www/error">
        AllowOverride None
        Options IncludesNoExec
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority en es de fr
        ForceLanguagePriority Prefer Fallback

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

[Sun Apr 08 04:09:43 2018] [error] [client] client denied by server configuration: /www/vhosts/vhosttest.com/httpdocs/
[Sun Apr 08 04:09:43 2018] [error] [client] client denied by server configuration: /www/vhosts/vhosttest.com/httpdocs/error

Latest Articles

  • prosody xmpp server "Failed in all attempts to connect to proxy.eu.jabber.org"
  • VMWare ESXi 6.7 SSH/PowerShell CLI Commands
  • VMWare Vsphere VCSA Graphical Install Creates json
  • error while loading shared libraries: libasound.so.2: cannot open shared object file: No such file or directory
  • ./xmr-stak: error while loading shared libraries: libmicrohttpd.so.10: cannot open shared object file: No such file or directory
  • qemu-img resize howto
  • gmail.com address failing in Postfix
  • VMWare Hardware virtualization is selected and cannot be deselected due to selection of VBS Insufficient resources to satisfy configured failover level for vSphere HA.
  • Debian Mint Ubuntu compiling xmr-stak
  • ./nsgpucnminer: error while loading shared libraries: libOpenCL.so.1w: cannot open shared object file: No such file or directory
  • *** These critical programs are missing or too old: gawk
  • migration/4 migration 4 is using too much CPU
  • convert.im6: Unknown field with tag 317 (0x13d) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/788.
  • Python SyntaxError: Missing parentheses in call to 'print'
  • Linux How To Rename Files
  • OpenVZ container will not stop Child 546246 exited with status 1
  • [warn] VirtualHost overlaps with VirtualHost, the first has precedence, perhaps you need a NameVirtualHost directive
  • Ethereum Client Errors
  • PayPal IPN Failed "result: IPN Handshake Invalid"
  • Linux Centos 7 HowTo Install Yarn