GetFree wrote:Now that I hid the .php from my public URLs, I want to send a 404 for every request to a .php file.
So I did the following:
RedirectMatch 404 \.php$
which works fine.
But the error page is the default apache error.
I want to show a custom error page, so I tried the following:
RedirectMatch 404 \.php$ /error.html
But it didn't work.
I dont know whether that directive will serve to do what I want.
In your httpd.conf file you commented out the link to the
custom error pages in the extra directory from an earlier post, I believe.
So add this to your .htaccess file after creating and naming your
custom error page (the name of the file is your choice, I used 404.htm as an example):
ErrorDocument 404 /404.htm
Put the page in the same place as the .htaccess file if using the above path or you can use a full path to where ever you want to put the
error page. You can even use
http://blah/blah/404.html etc.
You can customize other
error pages for example:
ErrorDocument 403 /403.html
ErrorDocument 500 /500.html
ErrorDocument 405 /405.htm
You can even use SSI to add environment variables to spruce up the
error page with what appears as very knowledgable
messages like these for example:
- Code: Select all
You were referred from this page: <!--#echo var="HTTP_REFERER" -->
Your IP address shows as: <!--#echo var="REMOTE_ADDR" -->
Your web browser says it is: <!--#echo var="HTTP_USER_AGENT" -->
You requested this page (error): http://<!--#echo var="HTTP_HOST" --><!--#echo var="REQUEST_URI" -->
The HTTP Status (error) Code is: <!--#echo var="REDIRECT_STATUS" -->
Remember to use the
.shtml file extension so Apache knows what it is.
I don't know if this will affect the same issue you had when we commented out the httpd-multilang-errordoc.conf or if you are still using that mod_rewrite rule or not.
This
custom error can also be change on a global basis from within the httpd.conf file using this block of entries:
- Code: Select all
# 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