2011-09-11 14 views
0

我怎樣才能做到這一點,mydomain.com/ - > mydomain.com/profile.php?username=的.htaccess與數據庫

現在,你可以通過像domain.com/

網址開始搜索我的htaccess文件是

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php?s=search&val=$1 [QSA,L] 

我可以在PHP文件

$val = $_GET['val']; 
if($c->userNameCheck($val)) 
{ 
    header("Location:".$url."/profile.php?username=".$val); 
} 

理解,但我不想展示profile.php

+3

爲什麼不'domain.tld/search/yoda'或'domain.tld/users/yoda'? – yoda

回答

1

你可以簡單地替換規則:

RewriteRule ^(.*)$ profile.php?username=$1 [QSA,L] 

但是,因爲你將不會被執行index.php文件,該userNameCheck方法不會被調用。如果提供的參數是有效的用戶名,我假設它會進行某種檢查 - 爲了使其與修改後的規則一起運行,您必須將該呼叫移至profile.php文件。