2013-07-19 37 views
0

我有以下htaccess文件不工作的htaccess重写规则正确

Options +FollowSymLinks 

RewriteEngine On 

#profile view 
RewriteRule ^([a-zA-Z0-9.]+)/?$ profile.php?id=$1 

当我去我的网址,并输入http://www.mysite.com/username

然后在profile.php文件我有

<?php 
    print_r($_GET); 
    die(); 
?> 

并打印出来

Array ([id] => profile.php) 

它应该打印出来

Array ([id] => "username") 

,所以我想有一些错误的,我重写规则?

回答

1

只是在末尾添加QSA:

RewriteRule ^([a-zA-Z0-9.]+)/?$ profile.php?id=$1 [QSA] 
+0

宾果,谢谢... – fxuser

+0

@fxuser希望它有助于:) – 2013-07-19 12:52:27

0

试试这个htaccess的代码:

RewriteEngine On 
RewriteRule ^([^/]+)$ /profile.php?id=$1 
+0

现在即时得到'内部服务器([id] => profile.php)' – fxuser

1
#profile view 
RewriteRule ^([a-zA-Z0-9.]+)?$ profile.php?id=$1 

尝试

编辑:(。*)?

重写规则^ $ profile.php ID = $ 1 [QSA]

RewriteR ?ULE ^([A-ZA-Z0-9] +)$ profile.php ID = $ 1 [QSA]

+0

仍然显示'Array([id] => profile.php)' – fxuser

+0

RewriteRule ^([a-zA -Z0-9] +)?$ profile.php?id = $ 1 [NC,L]尝试 – JohnnyFaldo

+0

事情是我想让点(。)能够放入URL中,当我将它们添加到模式它打破并显示该ID = profile.php – fxuser