2013-01-16 15 views
-2

我有XAMPP安裝在筆記本電腦與Mod Rewrite激活和運行。我有我的網站上的網頁如下:國防部重寫在查詢的PHP頁面

http://localhost/TripMan/staff/studentinfo/2 

我怎麼會寫一個重寫規則:

http://localhost/TripMan/staff/viewstudent.php?id=2 

我想就這樣,當有人訪問URL作爲它上面顯示去做這個?我以前從未使用過這個功能。

感謝

+0

嘗試搜索上堆棧溢出一點,我很相信你會找到答案。 – regilero

回答

1

您需要使用.htaccess文件像這樣:

# Turn on the rewrite engine 
RewriteEngine On 

# Set student rewrite 
RewriteRule ^TripMan/staff/studentinfo/([0-9]*)/?$ TripMan/staff/viewstudent.php?id=$2 [NC,QSA] 
+0

應該是'RewriteRule ^(/ TripMan/staff/studentinfo /)([0-9] *)$ TripMan/staff/viewstudent.php?id = $ 2 [NC,QSA]'? – symcbean

+0

@symcbean兩者都應該工作,僅僅是一個例子:-)將修改 –