Trying a require in a custom 404 page
Posted: Fri Jan 25, 2008 2:05 pm
HI all,
I am attempting to create a custom 404 page that redirects the user to a search result based on what the script thinks they were looking for. I have everything set up and it all works great, except for one thing.
I would like to have all the configuration performed externally, including the path to the search script. So, for instance, if my search script is in the "search" subfolder on my hosting account, the configuration (settings.php) would say something like:
And in the custom 404 page (called 404.php), I would like to require this settings file so I can refer to these constants
But this isn't working. If I set the constant within 404.php, it works (obviously), so I know it's got something to do with putting require in there, but I don't know how to solve it.
Oh, and if I echo $r, it gives me the correct full path (/home/tarview/public_html), so I know that part should be fine. Or is it? Could I be missing something there?
I am attempting to create a custom 404 page that redirects the user to a search result based on what the script thinks they were looking for. I have everything set up and it all works great, except for one thing.
I would like to have all the configuration performed externally, including the path to the search script. So, for instance, if my search script is in the "search" subfolder on my hosting account, the configuration (settings.php) would say something like:
Code: Select all
<?php
define( "_DOMAIN_", "www.example.com" );
define( "_SEARCHPATH_", "/search/" );
?>Code: Select all
<?php
$r = $_SERVER['DOCUMENT_ROOT'] . "/path/to/settings.php";
require( $r );
?>Oh, and if I echo $r, it gives me the correct full path (/home/tarview/public_html), so I know that part should be fine. Or is it? Could I be missing something there?