2016-07-30 79 views
1

搞亂我已經建立了改變這種連接的半工作.htaccess文件:

localhost/profile.php?id=6 

這樣:

localhost/profile/6 

然而,這增加。 PHP到我的$ _GET變量的末尾。我不太熟悉重寫模塊,.htaccess等,但這非常煩人。在網上找不到任何關於它的東西,如果有不同的方式來做或修復它,我將不勝感激任何輸入。

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^profile/(.*) profile.php?id=$1 
</IfModule> 
+1

你可以把你有什麼對的.htaccess規則。 – ArtisticPhoenix

+0

意思是包括它,對不起。更新了原來的帖子。 –

回答

1

嘗試限制到只有數字:

RewriteRule ^profile/(\d*) profile.php?id=$1 

或排除.,如果ID是不肯定的數字:

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

仍然沒有工作,6.php而不是「6」。 –

+0

@Ryan看到編輯。 – nicael

+0

兩者都很好,非常感謝 –