The code below work like this:
http://www.website.com/?page=home
will pull content from http://www.website.com/home.php
-- or --
http://www.website.com/?page=About
will pull content from http://www.website.com/About.php
Code:
// Set the default name
$action = 'home';
// Specify some disallowed paths
$disallowed_paths = array('admin');
if (!empty($_GET['page'])) {
$tmp_action = basename($_GET['page']);
// If it's not a disallowed path, and if the file exists, update $action
if (!in_array($tmp_action, $disallowed_paths) && file_exists("{$tmp_action}.php"))
$action = $tmp_action;
}
// Include $action
include("$action.php");
?>
The code above works fine for all my pages but now I have one custom link which I need to add http://www.website.com/?page=Search
to pull the content from http://www.website.com/search/search.php
instead of http://www.website.com/Search.php
How can I do that?
Thanks