Welcome to WebmasterWorld Guest from 126.96.36.199
I want any query on the root of the site to be processed by a script and return a page based on that query.
I dont think its wise to use a 404 error page to redirect because if it returns a 404 then the site wont be spidered. I dont know if i 301 redirect will still let google keep the original url, or if it will cause google to keep note of the "file processing" url.
In your .htaccess file you put something like:
rewriteRule ^([a-z0-9]+).htm$ /page.php?query=$1
Then whenever someone visits youdomain.com/anything-limited-to-letters-and-numbers.htm it will be served by the page.php script that uses the value of $query to determine the contents of the page. You can rewrite in any number of ways to create human-readable fully database driven sites.
You question about 200-OK responses brings up another point... Make sure your script *does not* provide 200-OK resonses to *all* queries. If you don't have something useful to serve, then have php write a 404 response header. Search engine spiders are very leery of sites where they *cannot* get a 404 - even by trying - because they then suspect that the URL-space of the server is infinite - that it will never retuirn 404. So, they artificially limit the depth of spidering on such sites.
>> have php write a 404 response header
That's a php question - something I am singularly unqualified to answer.
It's response.header.write or something like that...
On a deeper level, your script has got to 'know' what queries it has an answer to. So the answer very much depends on what kind of site you've got, and is likely well beyond the scope of our little forum here.
On a database-driven site, you'd query the database and return a page if you found query-related data. Otherwise, you'd return a 404-Not Found response -- remember, the browser or spider thinks this is a real html page it's asking for.