Forum Moderators: coopster
First off, if this topic is posted elsewhere on the site, sorry. I searched through 9 similar topics, but none answered my question.
I read that a "fix" to the problem that some search engines have with a dynamic page could be solved with a 404 error redirect. For example, instead of somepage.php?category=cars&name=mustang you could link to a nonexistant page of /cars/mustang/somepage.php. When the server doesn't find that page, it redirects to the page set in .htaccess, and you can explode the referring URL.
The tutorials I read said to use
$url = explode("/",$REQUEST_URI);but this wouldn't work because $REQUEST_URI is delivering the 404.php and any variables after the? (which are what I want to avoid). So I tried
$url = explode("/",$_SERVER['HTTP_REFERER']);and its not picking up the referer at all.
Is this because of a variable set in php.ini or httpd.conf. Or do the server variables for my browser get reset when apache redirects through .htaccess, or maybe something else?
Thanks
AFAIK this will make it very difficult to track down real 404 errors, because every page request will be logged as a 404 in the access_log.
we use a rewrite rule to do something similar, by appending the non-existant SCRIPT_URL to our page generation script:
RewritEngine On
RewriteRule ^(.*)$ html.php/$1 [L]
in html.php we explode the SCRIPT_URL to get the params to query the db.
this also doesn't work too well with the access_logs, as no page is ever actually logged as a 404. to get round this, if the db query returns no results, we manually send a 404 header and 404 page and write to our own error log.
HTH
Anyway, when I define an error page on my server like this in .htaccess or httpd.conf:
ErrorDocument 404 /error/404.php
, $_SERVER['REQUEST_URI'] contains the non-existent URL, not the 404.php. So I wonder whether you're using the ErrorDocument thingy?