Search Bot w/ PHP template system?

I have a content/template system (really simple one) The way it is set up is as follows:

There is one php script “index.php” that is used for displaying all pages. Each page is a seperate file that is then included in index.php?p=page. The way it loads a page is [color=Navy]$_GET[/color][[color=DarkRed]‘p’[/color]]; For example:

$pageid = $_GET['p'];
if (file_exists($pageid . ".php"){
   $pagetoload = $pageid . ".php";
   $pagetoload = "error404.htm";

I was wondering… how will this work with search engines? Should I have the proper <title>data</title> and meta tags in each seperate file, then have it so that if a user accesses them via a search engine or other means it redirects them to the proper templated page? (index.php?p=thepage) But if I do that then the <head> block would be in the body block… unless I broke the <body> block into two…

Sorry if this doesn’t make much sense :frowning: If you need me to re-explain it I would be happy to.

Thanks in advance for any help or guidance :hugegrin: