2016-12-14 118 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]