【发布时间】:2012-03-26 10:13:34
【问题描述】:
这是我的 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
更多信息。有我的项目路径,其中index php是:
C:\xampp\htdocs\PHPTest
【问题讨论】:
-
RewriteRule的参数不是倒序吗?the server doesn't produce this是什么意思? -
它不起作用/////////
-
我不能说您的评论更能说明您面临的问题。更清楚您想要实现的目标以及目前正在发生的事情。
-
网址不显示为 index.php/article_27.. 如答案中所述
-
您的新规则将不起作用 -- 查询字符串无法与 RewriteRule 匹配。对于查询字符串,请使用
RewriteCond %{QUERY_STRING} PATTERN_HERE,然后使用%1而不是$1引用它(查看 mod_rewrite 文档:httpd.apache.org/docs/current/mod/mod_rewrite.html)。