以下のコードは次のように機能します。
http://www.website.com/?page=home
からコンテンツをプルしますhttp://www.website.com/home.php
- また -
http://www.website.com/?page=About
からコンテンツをプルしますhttp://www.website.com/About.php
コード:
// 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");
?>
上記のコードはすべてのページで正常に機能しますが、コンテンツをプルするために追加する必要のあるカスタムリンクが1つあります。http://www.website.com/?page=Search
http://www.website.com/search/search.php
http://www.website.com/Search.php
どうやってやるの?
ありがとう