简体   繁体   中英

Problems using ErrorDocument httpd.conf

Using the httpd.conf file*, I hope to create ErrorDocument handlers that redirect the user to a certain website. The code on the error page is:

<?php
header("Location: http://www.mydomain.com/?error=true");
?>

I'm using the syntax: ErrorDocument 404 /error.php, and error.php is in the same directory as the httpd.conf file. After restarting my server, the error 404 page says "Not Found

The requested URL /404page was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

What path should I use? *I want to use the httpd.conf file, not .htaccess.

Try this

read here about http status codes http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

# 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

I solved the problem by putting the file in a directory relative to the httpd.conf file:
ErrorDocument 404 /error/index.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.

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