Forum Moderators: coopster
<a href="http://mysite.com/?i=1">Link Text</a> <?php
$var = $_GET['i'];
switch ($var) {
case 1:
include '1.php';
break;
case 2:
include '2.php';
break;
case 3:
include '3.php';
break;
default:
include 'notlost.php';
}
?> <?php
$var = $_GET['i'];
if ($var =='')
include 'notlost.php';
else
include "$var.php";
?>
<?php
$var = strip_tags($_GET['i']);
if ($var =='')
include 'notlost.php';
else
include "$var.php";
?>
[edited by: Matthew1980 at 10:13 pm (utc) on Jun 6, 2010]
if (
(isset($_GET['i']) and is_numeric($_GET['i']) and ($_GET['i'] > 0)
and is_file($_SERVER['DOCUMENT_ROOT']."/".$_GET['i'].".php")
) {
$include = $_SERVER['DOCUMENT_ROOT']."/".$_GET['i'].".php";
}
else {
include($_SERVER['DOCUMENT_ROOT']."/notlost.php");
}
include($include);
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^([A-Za-z0-9]+)$ /index.php?i=$1 [L] <?php
$var = strip_tags($_GET['i']);
if (file_exists("$var.php"))
{
include "$var.php";
}Else{
include '0.php';
}
?> What WON't go to index.php,
/some-file
/some_other_file
Just a question, is this experimental or intended for a live site? The reason I ask is
example.com/4
Is not a real fruitful URL in terms of SEO and user experience, but
example.com/buy-cool-widgets
might be.
A direct request to a domain root won't, but that will probably go to index.php by default if you don't have an index.htm(l). So again, 0.php