URL重写模块扰乱$_GET变量


URL Rewrite Module messing with $_GET variables

我建立了一个半工作的.htaccess文件,它改变了这个链接:

localhost/profile.php?id=6

到此:

localhost/profile/6

不过,这是在$_GET变量的末尾添加.php。我对重写模块、.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>

尝试仅限于数字:

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

或者排除.,如果ID不一定是数字:

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