爲什麼不妳的.htaccess使用
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule
^(.*)/?$ index.php?page=$1 [L]
</IfModule>
然後你index.php你將返回相應的頁面:
# SELECT WHICH PAGE TO DISPLAY
function getPage($showPage) {
$modules = array(#never name the slugs as same as the php pages
'/sign-in/i' => 'register.php',
'/signout/i' => 'logout.php',
'/staff/i' => 'admin.php',
'/products/i' => 'blank.php',
);
foreach ($modules as $slug=>$phpmodule) {
if(preg_match($slug, $showPage)) {
return $phpmodule;
}
}
return 'blank.php';#in case module not found display 404 page
}
if (isset($_GET['page'])) {
require_once (getPage($_GET['page'])); #include the appropriate module file
}
有很多方法可以做到。我希望這給你一個想法,你可以開始,如果我的答案已被用於你,請投票或接受答案。
你也應該[檢查你的'.htacess'文件是否已經加載](http://httpd.apache.org/docs/2.0/howto/htaccess.html#when)。如果您有root權限,請考慮[根本不使用'.htacess'文件](http://httpd.apache.org/docs/2.0/howto/htaccess.html#when) – Max 2014-10-22 10:04:12