Forum Moderators: phranque

Message Too Old, No Replies

How can you redirect ALL 404 pages on a server to a single php file?

         

vaxop

7:59 am on Jun 5, 2007 (gmt 0)

10+ Year Member



I have like 40 domains on a server and Id like all 404 pages (including all subdomains) to be redirected to a single php file (passing the requested URL to the script)

Anyone know how to do this?

phparion

8:07 am on Jun 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I guess it can be done with http.conf found under /etc/httpd/conf/http.conf

ErrorDocument 404 /404.php

so that it will be implemented throughout the server

vaxop

8:54 am on Jun 5, 2007 (gmt 0)

10+ Year Member



thanks :)
also, how can i pass the URL that was requested to the php file?

jdMorgan

1:33 pm on Jun 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It should be available in a server variable -- REQUEST_URI is what it's called at the server level, and PHP's name for it will be similar.

Jim

jatar_k

1:35 pm on Jun 5, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the varname in php is exactly the same $_SERVER['REQUEST_URI']

[php.net...]

vaxop

8:55 pm on Jun 5, 2007 (gmt 0)

10+ Year Member



ah
but how would I be able to tell the domain that was requested?
wont URI just give the file?

jdMorgan

9:45 pm on Jun 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check HTTP_HOST -- and any others you might want or need. :)

Jim