Apache/htaccess中的重写规则不';行不通

Apache/htaccess中的重写规则不';行不通,apache,.htaccess,Apache,.htaccess,这是我的htaccess文件中的内容,该文件与我的php项目位于同一目录中: Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / 我的页面上有一个链接将用户发送到此地址: http://localhost/PHPTest/index.php?article=27 这是我想要的输出==index.php/article_27 更新: 当我按下链接时,这是url中的输出: http://localhos

这是我的htaccess文件中的内容,该文件与我的php项目位于同一目录中:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On

RewriteBase /
我的页面上有一个链接将用户发送到此地址:

http://localhost/PHPTest/index.php?article=27
这是我想要的输出==
index.php/article_27

更新:

当我按下链接时,这是url中的输出:

http://localhost/PHPTest/index.php?article=27
应在我的php项目文件夹中的.htaccess中截取该文件,并将其交换到以下位置:

 http://localhost/PHPTest/index.php/article_id_27
这是我的重写规则。但它不起作用:

RewriteRule ^index.php?article=([0-9]+)$ index.php/article_id_$1 
更多信息。这是我的项目路径,其中索引php为:

C:\xampp\htdocs\PHPTest

url本身不显示为index.php/article_27

为什么会这样?您将链接指向
…article=27
,您的规则将
…article\u 27
重写为
…article=27


在您给出的场景中,您可能希望从
…article=27
重定向到
…article\u 27
,而不是重写。

重写规则的参数不是按相反顺序吗?你所说的
是什么意思?服务器不产生这个
?它不起作用了,我不能说你的评论进一步说明了你所面临的问题。更清楚地了解您想要实现的目标以及目前正在发生的事情。url不会显示为index.php/article_27。。正如回答中所解释的,您的新规则将不起作用——查询字符串不能与重写规则匹配。对于查询字符串,在这里使用
RewriteCond%{query\u string}模式
,然后使用
%1
而不是
$1
(检查mod\u rewrite docs:)。我想使用这个模式:RewriteRule ^oldfile\.html newfile.html//这基本上就是我想要的。。。请参阅更新