Apache htaccess重写规则-url参数

Apache htaccess重写规则-url参数,apache,.htaccess,url-rewriting,Apache,.htaccess,Url Rewriting,这可能是难以置信的简单,但我已经通过几个链接,无法找到答案,我正在寻找 我的网址: www.website.org/shows/index.php?id=1 所需重写: www.website.org/shows/id/index.php 我知道我需要使用Apache的.htaccess中的RewriteRule,我只是不知道如何让它匹配然后重写 我失败的尝试: RewriteRule ^/shows/index.php?id=([0-9])$ shows/$1/index.php 您的重写规

这可能是难以置信的简单,但我已经通过几个链接,无法找到答案,我正在寻找

我的网址:

www.website.org/shows/index.php?id=1

所需重写:

www.website.org/shows/id/index.php

我知道我需要使用Apache的.htaccess中的RewriteRule,我只是不知道如何让它匹配然后重写

我失败的尝试:

RewriteRule ^/shows/index.php?id=([0-9])$ shows/$1/index.php

您的重写规则应该是这样的:

RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^shows/index\.php$ /shows/%1/index.php

有一个非常好的官方文档,解释了如何在重写规则中访问quesry sting:

非常感谢您的回答!谢谢你10倍以上的非常有用的链接!!!非常感谢!!