mod_rewrite一个url字符串

时间:2012-04-10 18:07:42

标签: mod-rewrite

有人可以告诉我如何让mod_rewrite重命名:

our-work-section.php?id=3&title=something
to
our-work-section/something/3

现在我的.htaccess位于目录 C:\ workspace \ www \ brown ,我的vhost设置为 http:// workspace / ,所以我做了一个RewriteBase如下。我目前有:

RewriteEngine On
RewriteBase /www/brown/
RewriteRule ^/our-work-section/?$    our-work-section.php?id=$1 [NC,L]

我的错误日志没有说什么,页面也没有做任何事情。我试过在这里和那里切换斜线。

1 个答案:

答案 0 :(得分:1)

试试这个

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(our-work-section)/?$ /our-work-section.php?id=$1 [L]

修改

这个会奏效。我测试了它

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(our-work-section)/([^/\.]+)/?$ /our-work-section.php?id=$1 [L]