What I want to do is letting the user enter a searchstring in the commandline and redirect him to the appropriate page. e.g.: the user types: www.mydomain.com/something and I direct him to www.mydomain.com/page.php?id=27408
What I have is a command in the .htaccess : ErrorDocument 404 /index_404.php so the request is sent to my php-script searching my database for the correct id and leading him to the requested page. – And this works fine.
Unfortunately there is a lot of traffic as every 404 error (e.g. some picture not found) is sent to that php-page and disturbs me. I had a solution with redirect 301 – but the server of my provider is not letting me generate a .htaccess by php-script.
So my question: Is there a way to check the request if it matches only letters and redirect only these requests. Something like:
ErrorDocument 404 (where request in [a..z]) /index_404.php
And letting the rest handle by Default? If so please send a decent example.
Here the basic code from my php-script:
if (isset($_SERVER["REQUEST_URI"])) {
$in = $_SERVER["REQUEST_URI"];
$in = str_replace("/","",$in); //
dbconnect();
$sql = 'select * from menu where REPLACE(menu," ","") = "'. $in;
$result = @mysql_query($sql);
if ($data = @mysql_fetch_array($result)) {
$out = 'page.php?id='.$data['id'];
}
}
if (isset($out)) {
header("Location: ".$out);
} else {
header("Location: "."index.php");
}