470,833 Members | 1,422 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

404 error handling

Hi,

I know how to handle all my 404 errors, if I get any :).

But sometime the user will type something wrong so instead of going to
www.example/about.php they will ask to go to www.example/abkut.php.
How could I do an SQL search for the word 'abkut.php' that would return
'about.php' as a possible match for the page?

Many thanks

Sims.
Jul 17 '05 #1
3 1378
Sims wrote:
I know how to handle all my 404 errors, if I get any :).

But sometime the user will type something wrong so instead of going to
www.example/about.php they will ask to go to www.example/abkut.php.
How could I do an SQL search for the word 'abkut.php' that would return
'about.php' as a possible match for the page?


Assuming you've got an SQL database containing your page names, you
might try using a SOUNDEX comparison. For MySQL see:
http://dev.mysql.com/doc/mysql/en/String_functions.html

If you're running on Apache, Apache itself has a module for detecting
near-misses that might be more direct:
http://httpd.apache.org/docs-2.0/mod/mod_speling.html

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #2
"Sims" <si*********@hotmail.com> wrote in message news:<c7************@ID-162430.news.uni-berlin.de>...
Hi,

I know how to handle all my 404 errors, if I get any :).

But sometime the user will type something wrong so instead of going to
www.example/about.php they will ask to go to www.example/abkut.php.
How could I do an SQL search for the word 'abkut.php' that would return
'about.php' as a possible match for the page?


You may look at the source code of php.net
<http://in2.php.net/source.php?url=/include/manual-lookup.inc>
eg. php.net/strlenn will fetch php.net/strlen
^^
--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #3
Lookup similar_text() on php.net. You could use that in a loop to
read through the last legit directory and allow users to pick from the
most similar legit direcories/files.

http://www.yourdomain.com/one/two/thee/four/

"Sims" <si*********@hotmail.com> wrote in message news:<c7************@ID-162430.news.uni-berlin.de>...
But sometime the user will type something wrong so instead of going to
www.example/about.php they will ask to go to www.example/abkut.php.
How could I do an SQL search for the word 'abkut.php' that would return
'about.php' as a possible match for the page?


Shawn
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Christian Christmann | last post: by
13 posts views Thread by Thelma Lubkin | last post: by
3 posts views Thread by Stefan Johansson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.