使用php变量执行301重定向时卡住

使用php变量执行301重定向时卡住,php,.htaccess,Php,.htaccess,我正在尝试在.htaccess文件中写入301,但无法使其工作。我们的url如下所示 http://www.example.com/?cat=tree-category http://www.example.com/?cat=food-category 我们想将这些更改为 http://www.example.com/directory/listings/tree-category http://www.example.com/directory/listings/food-categor

我正在尝试在.htaccess文件中写入301,但无法使其工作。我们的url如下所示

http://www.example.com/?cat=tree-category

http://www.example.com/?cat=food-category
我们想将这些更改为

http://www.example.com/directory/listings/tree-category

http://www.example.com/directory/listings/food-category
请任何人帮忙,我们将不胜感激

詹姆斯

这应该可以做到:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/$
RewriteCond %{QUERY_STRING} ^cat=([a-zA-Z0-9\-]*)$
RewriteRule ^(.*)$ http://www.example.com/directory/listings/%1 [R=301,L]

退房:

嗨,布莱恩,恐怕不行。我想不出来-我正在使用Wordpress,我知道它有一些内置的重定向,但它应该仍然可以工作。想发布你的.htaccess文件吗?没有更多的信息,我们真的帮不上忙。