IN MY LOCAL (WAMP) SERVER:
I have this .htaccess file
Options +FollowSymLinks
RewriteEngine On
ErrorDocument 404 /views/oops.php
ErrorDocument 500 /views/oops.php
ErrorDocument 400 /views/oops.php
In my httpd.conf this line is Uncommented
LoadModule rewrite_module modules/mod_rewrite.so
The HTACCESS File is in the application root folder. When I visit this URL:
localhost/mywebapp/views/home.php
It works perfect, shows the home page. And if I enter something like
localhost/mywebapp/views/thisdoesnotexist OR localhost/mywebapp/thisdoesnotexist
I want it to show me my error page, but it's showing the default and ugly error page.
Thank you beforehand.
EDIT: This is what it shows on error
Not Found
The requested URL /myapp/thisdoesnotexist was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I'm guessing that the oops.php
file is actually in the mywebapp folder, as opposed to the document root. The path that the ErrorDocument
directive takes is an absolute URL, not relative to where the htaccess file is in. So you need to make sure the path points to the actual location of the error document:
ErrorDocument 404 /mywebapp/views/oops.php
ErrorDocument 500 /mywebapp/views/oops.php
ErrorDocument 400 /mywebapp/views/oops.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.