Regex .htaccess在传递带有参数的URL时重写wamp服务器中的文件夹名称

Regex .htaccess在传递带有参数的URL时重写wamp服务器中的文件夹名称,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,这是我的.htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ /PM/$1.php [NC,L] 我的项目位于c:/wamp/www/PM/ HTML示例: a href=“messages.php” 通过将URL生成为localhost/PM/messages/(注意结尾处的/),上述URL可以正常工作 但是当我使用url作为 a href=“消息?id=1” 上面的链接生成

这是我的.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ /PM/$1.php [NC,L]
我的项目位于c:/wamp/www/PM/

HTML示例:

a href=“messages.php”

通过将URL生成为localhost/PM/messages/(注意结尾处的/),上述URL可以正常工作

但是当我使用url作为

a href=“消息?id=1”


上面的链接生成的URL为localhost/messages/?id=1(我想知道在URL中传递参数时/PM是如何消失的),页面上显示“请求的URL/messages/在此服务器上找不到”。

请在
/PM/.htaccess
中尝试此代码:

RewriteEngine On
RewriteBase /PM/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]

在您的
/PM/.htaccess
中尝试此代码:

RewriteEngine On
RewriteBase /PM/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]

您在
/PM
目录中也有.htaccess吗?还有其他规则吗?这个.htaccess本身在PM文件夹中还有另一个问题。还有其他规则吗?没有。只有这三行您才能在
/PM
目录中访问.htaccess?还有其他规则吗?这个.htaccess本身在PM文件夹中还有另一个问题。还有其他规则吗?没有。只有那三行