Hi
problem i've got...
I have just rewritten my URLs with mod_rewrite for the apparent need of SEO friendlyness these days, i did it primarily because Google was doing a good job of ignoring me.... and apparently it worked, as G now seems to correctly index me.. for now!
it seems though that i have left a loop hole, that hole being the return of 200 success for non existant URLs. So i'm looking for away to catch the offenders and redirect to either a dynamic error message 404 page or the index page whichever you gurus may perhaps see fit. an example of an original link to a rewritten link is like so:
w3.mysite.tld/index.php?cat=cat1 to -> w3.mysite.tld/cat1
problem being that if cat4 for example didnt exist it would just go ahead and load that page up anyway with allsorts of sql database error messages and produce a 200 success header.
i use a template for most of the site which works along these lines:
<?php
if (!$_GET['cat'] || $_GET['cat'] == "")
{
include("content/main.php");//nothing is set so include main content.
}
else if (!$_GET['story'] || $_GET['story'] == "")
{
$display = $_GET['cat'];
include("content/$display.php");
}
else
{
$story = $_GET['story'];
$find_news = mysql_query("SELECT * FROM news WHERE title = '$story'");
while($got_news = mysql_fetch_array($find_news))
{
$title = $got_news['title'];
$news = $got_news['news'];
echo("<div class=\"detail\">");
echo("<h2>$title</h2>");
echo("<p>$news</p>");
echo("</div>");
}
}
echo("\n");
?>
so i'm looking for a lean way to test to see if a filename exists in my content folder or if a story exists in the database?
ie:
if(filename(.php)/directory/dbentry(article/story) doesnt exist)
{
return a 404 missing and redirect to missing page and/or stick a custom error message up
}
regards
sean