如何编写Apache重写规则


How to write the Apache rewrite rule?

目前我有这样的url:

http://example.com/d/tag.php?n=1&tag=php
http://example.com/d/tag.php?n=1&tag=cms

我想在.htaccess文件中添加重写规则。让URL像这样:

http://example.com/tag/1/php

如何编写这样的规则?

给你:

 RewriteEngine On
 RewriteRule ^tag/([0-9]*)/(.*)$ tag.php?n=$1&tag=$2

别忘了把它放在目录(d)下的.htaccess文件中

看看这个链接

mod_rewrite重定向所有的请求链接http://exmple.com/d/tag.php?n=1&tag=php到一个特定的页面,在那里你必须编写处理请求的代码

希望能有所帮助