2013-07-19 39 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