它可以通過.htaccess發送查詢到另一個文件? 有點解釋:QUERY_STRING在PHP中處理
的index.php處理所有的網頁是這樣的:
switch($page) {
case 'index':
require_once START . '/includes/pages/index.php';
break;
case 'another':
require_once START . '/includes/pages/another.php';
break;
and so on...
在.htaccess:
RewriteRule ^index$ index.php?page=index [L]
RewriteRule ^another$ index.php?page=another [L]
鏈接(例如本地主機/ 84ss7d41):
RewriteRule ^(.*)$ index.php?QUERY_STRING=$1 [L]
所以在/includes/pages/index.php:
if ($_GET['QUERY_STRING']) {
$_SERVER['QUERY_STRING'] = $_GET['QUERY_STRING'];
$query_string = check_input($_SERVER['QUERY_STRING']);
//checking/validating processing further...
如何使這樣一個本地主機/ 84ss7d41以相同的方式工作環節和現在一樣,但沒有的index.php?我想單獨我的「項目」,如果事情會發生(文件誤刪除)檢查/驗證的數據將工作一樣,沒有主腳本,它是這樣的:
if (main project file index.php/ || /includes/pages/index.php doesn't exist) {
check/validate data with reserve.php
}
如果您想稍後避免麻煩,請勿覆蓋'$ _SERVER'陣列的成員。你試圖達到的目標應該是可能的,但你必須更清楚你想要達到的目標。 – hakre 2012-03-11 16:23:07
你能澄清你的問題嗎?你想創建像'localhost/84ss7d41'這樣的鏈接,或者你想在index.php不存在的時候重定向用戶?你想要什麼? – MahanGM 2012-03-11 19:02:45
@MahanGM正好,只要index.php不存在 – ZeroSuf3r 2012-03-12 11:30:41