國防部重寫我做的方式,這將使它簡單,但很難在同一時間。
的.htaccess檔中的_ __ _ __ _ __ _ __ _ ____
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /main site folder/
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
</IfModule>
/classes/simplifyURL.php FILE_ _ __ _ __ _ __ _ __ _ _
<?php
class simpleUrl{
var $site_path;
function __construct($site_path){
$this->site_path = $this->removeSlash($site_path);
}
function __toString(){
return $this->site_path;
}
private function removeSlash($string){
if($string[strlen($string) - 1] == '/')
$string = rtrim($string, '/');
return $string;
}
function segment($segment){
$url = str_replace($this->site_path, '', $_SERVER['REQUEST_URI']);
$url = explode('/', $url);
if(isset($url[$segment]))
return $url[$segment];
else
return false;
}
}
?>
頂部的index.php _文件_ __ _ __ _ ___
<?php
include 'classes/simplifyURL.php';
$url = new simpleUrl('/main site folder');
$url1 = $url->segment(1);
$url2 = $url->segment(2);
$url3 = $url->segment(3);
$url4 = $url->segment(4);
?>
包括網頁到index.php中基於關閉URL_ _ __ _
<?php
$pages_dir = 'pages';
if (!empty($url1)) {
$pages = scandir($pages_dir, 0);
unset($pages[0], $pages[1]);
$p = $url1;
if (in_array($p.'.inc.php', $pages)) {
include($pages_dir.'/'.$p.'.inc.php');
} else {
echo 'Sorry, page was not found.';
}
} else {
include($pages_dir.'/home.inc.php');
}
?>
這是你必須make.Anyway一個巨大的轉變,讓我解釋一下上面的部分。它需要url的第一位的值,所以緊跟在域後面並檢查文件夾頁面,如果它能找到它,它會顯示它。所以對於你的情況,你需要創建一個名爲user.inc.php的文件。將身份驗證放入它中,並使用$ url2變量來訪問網址的結尾,以獲取您擁有的長代碼。其他明智的動態頁面。希望這有助於
這是很多的工作,我看不出什麼錯與GET
查找國防部重寫 – 2013-06-27 22:33:36
「如何避免404錯誤?」帶有RewriteRules的'.htaccess'文件。 – Sammitch
限制#1,您將需要使用mod_rewrite將querystring參數轉換爲「漂亮」url – Matt