简体   繁体   中英

PHP 404 Error Not Redirecting

So while editing my .HTACCESS file I added the proper lines to redirect users that encounter errors like 404 and 500. It works like a charm if I tell it to display a specific message. However if I tell the file to redirect users to a custom error page it fails. When testing out my 404 redirect I get this:

Not Found
The requested URL /143/test.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80

As you can see it is stating that my ErrorDocument is not found BUT if I type my ErrorDocument URL in I can go to it myself. My .HTACCESS file looks like this:

ErrorDocument 400 /error.php
ErrorDocument 401 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
ErrorDocument 502 /error.php
ErrorDocument 504 /error.php

php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# enable PHP error logging
php_flag log_errors on
php_value error_log PHP_errors.log

NOTE: I am using localhost (WAMP). Thanks.

You were looking for a file called "/143/test.php" , but (usually) yout .htaccess goes in the web root. .htaccess is looking for error.php in the /143 directory, so put a copy of it there or use an absolute URL in your .htaccess

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM