I have a domain on which I am trying to set custom redirects for the error pages.
My .htaccess file looks like so:
RewriteEngine On AddDefaultCharset UTF-8 DefaultLanguage en-US # disable TRACK and TRACE http methods. 'RewriteEngine On' is required! RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD|PUT|DELETE) RewriteRule .* - [F] Options All -Indexes ServerSignature Off <ifModule mod_headers.c> Header unset X-Powered-By </ifModule> <Files .htaccess> order allow,deny deny from all </Files> <IfModule php5_module> php_value session.cookie_httponly true #php_value session.cookie_secure true </IfModule> RewriteCond %{QUERY_STRING} _escaped_fragment_=(.*) #to block all links to '.gif', '.jpg','.js' and '.css' files which are not from the domain name 'http://www.example.com/' RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC] RewriteRule \.(gif|jpg|css|js)$ - [F] #to deny requests containing invalid characters RewriteBase / RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9\.\+_/\-\?\=\&]+\ HTTP/ [NC] RewriteRule .* - [F,NS,L] # Secure directories by disabling execution of scripts AddHandler .php .pl .py .jsp .asp .htm .shtml .sh .cgi Options -ExecCGI #Error page handeller ErrorDocument 400 /htaccessSample/errordocs/error-code.php ErrorDocument 401 /htaccessSample/errordocs/error-code.php ErrorDocument 403 /htaccessSample/errordocs/error-code.php ErrorDocument 404 /htaccessSample/errordocs/error-code.php When I type something on the URL like so:
example.com/aboutUs: Everything works normally.example.com/xxygsds: The URL is redirected to the custom 404 error page.example.com/<>: This redirects to the 403 forbidden page. However, the redirect is to theapache/error/HTTP_FORBIDDEN.html.varpage and not to the custom page as mentioned above.
My questions:
1. Why is this redirect happening?
2. How can I have it redirect to the custom 403 error page in all conditions?