2016-12-14 122 views
0

我爲面臨着我從URL接收ID,並顯示它只是腓重寫網址.htaccess文件

http://localhost/test/?username=bingo123

其工作正常,問題顯示結果

但我想,我應該能夠寫出這樣

http://localhost/test/bingo123

我試圖讓.htaccess文件,但它不能正常工作,並顯示

所請求的網址/測試/ bingo123此服務器

Rewriteengine on 
Rewriterule ^([a-zA-z]+)$ index.php?username=$1 

我想上找到要知道我應該改變.htaccess文件或Wamp中的一些其他設置來運行腳本,我應該在哪裏保存.htaccess以便它能夠工作很好。在這裏「測試」文件夾名稱,其中包含所有php文件以及如何保存.htaccess文件,因爲它不允許它保存沒有名字。

在此先感謝。

+0

可能的複製(http://stackoverflow.com/questions/13003319/ htaccess-rewrite-query-string-as-path) – Fiddles

回答

1

嘗試像[重寫的.htaccess查詢字符串作爲路徑]這

RewriteEngine On 
RewriteRule ^test/([^/]*)$ /test/?username=$1 [L] 
+0

它仍然顯示錯誤。不檢測 –

0

Myabe有用

RewriteRule ^test/([a-zA-Z]+)$ test.php?username=$1 [L] 
RewriteRule ^test/([a-zA-Z]+)/([a-zA-Z]+)$ test.php?username=$1/$2 [L] 
RewriteRule ^test/([a-zA-Z]+)/([0-9]+)$ $ test.php?username=$1[L] 
0
RewriteEngine On 

RewriteRule ^test/([a-zA-Z0-9-=_.]+)$ test.php?username=$1 [L]