Page is a not externally linkable
calvinmicklefinger - 4:26 am on Jun 7, 2010 (gmt 0)
This is what I wound up with. It seemed to simplify a lot of things and handles a lot of different situations. Please remember, I aren't no coder, so I hope it is bug proof. Please advise if it amn't.
In my .htaccess ... DirectoryIndex index.php
RewriteEngine On
RewriteRule ^([A-Za-z0-9]+)$ /index.php?i=$1 [L]
In my index.php ... <?php
$var = strip_tags($_GET['i']);
if (file_exists("$var.php"))
{
include "$var.php";
}Else{
include '0.php';
}
?>
Seems to work so far, and handles missing pages. But, as you say, it could run phpinfo.php if I accidentally wind up with it in my root.
I don't know enough code to understand the globals you are using ... What do you think I can do to make this better? How can I protect against things like code injections?