Forum Moderators: phranque
Task: Redirect requests of a member's URL or a listing ID
http://www.example.com/JohnDoe
http://www.example.com/1234567
To their page, or appropriate listing.
The way we're doing it is using an .htaccess file:
ErrorDocument 404 search_script?d=1
And the query string, still in %ENV, is parsed out to produce the page.
This has worked for years for 99.99% of the visitors. But that .001%, almost ALWAYS AOL users, get "Page cannot be displayed." (They also scream the loudest.) Unfortunately all I can get out of them is the bottom of the page, "Cannot find server or DNS error."
Is there a better way to do this that will fix this once and for all?
Thank you so much for looking. :-)
If so, then the following method using mod_rewrite might work better:
# IF requested URL does not resolve to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# AND IF requested URL does not resolve to an existing file
RewriteCond %{REQUEST_FILENAME} !-f
# THEN internally rewrite the request to the search script
RewriteRule ^/(.+)$ /search_script?d=1 [L]
This is not the most efficient way to do things, because every request will result in at least one filesystem check. Anything you can do to constrain these checks would help. For example, if you could require them to prepend "/user/" or "/~" or anything similar onto their requests, then only those URLs starting with "/user/" or "/~" would need to be checked. Or you could move the usernames into subdomains, and then check only that the requested subdomain is not www or blank, avoiding the filesystem check altogether. But if this is an existing system, then you're probably stuck with inefficient methods to support legacy users. It should still be faster than using the 404 ErrorDocument method, though.
404 ErrorDocuments and server responses should be used for only one purpose, and that is to inform the user that the URL he/she requested cannot be found on the server for reasons that could not be determined. If a page is removed intentionally, it should return a 410-Gone response. Any use of these handlers and server response codes for non-error-handling purposes eventually backfires, either in technical difficulties (such as the inefficiency noted above) or in problems with search engine rankings. If it also 'breaks' AOL, then that's a third argument against 'stretching' the HTTP protocol [w3.org].
Jim
Thank you again.