此网址的mod-rewrite规则

时间:2012-09-04 14:32:47

标签: php mod-rewrite

你能帮忙为这个网址创建一个模拟重写规则吗

http://localhost/view.php?item_id=28&sef=2009-bristol-blenheim-in-west-yorkshire

我希望它转到

http://localhost/view.php?item_id=28

我希望我的链接看起来像这样

http://localhost/view/28/2009-bristol-blenheim-in-west-yorkshire

我目前正在将此规则用于其他页面

RewriteRule ^category/[!/.]*([A-Za-z]+)/?$ /browse.php?cat=$1    [NC,L]

但似乎无法更新它以适应这个......

当前的htaccess

RewriteEngine On
Options +FollowSymLinks

# Browse Category
RewriteRule ^category/[!/.]*([A-Za-z]+)/?$ /browse.php?cat=$1    [NC,L]

# View Item
RewriteRule ^view/([0-9]+)/([a-zA-Z0-9-]+)$ /view.php?item_id=$1&sef=$2 [NC]

浏览类别正常,查看项目不是

1 个答案:

答案 0 :(得分:0)

如果您需要

等请求
http://localhost/view/28/2009-bristol-blenheim-in-west-yorkshire

以静默方式成为

的服务器请求
http://localhost/view.php?item_id=28&sef=2009-bristol-blenheim-in-west-yorkshire

然后试试这个:

RewriteRule ^view/([0-9]+)/([a-zA-Z0-9-]+)$ /view.php?item_id=$1&sef=$2 [NC]