带参数的重写已经编入索引

时间:2014-02-21 09:01:05

标签: php .htaccess mod-rewrite

我的网站上有像ref.php这样的网址?id = 2已被Google编入索引。 我知道如何使用以下规则在我的网址中添加关键字:

RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^ref.php$ http://www.website.fr/boat? [R=301,L]

但是,我不知道如何将旧网址重定向到新网址。 如果我这样做

RewriteRule ^boat$ /ref.php?id=2 [L]

我有一个错误。

我找到的唯一解决方案是将ref.php复制到ref2.php中 并添加此规则

RewriteRule ^boat$ /ref2.php?id=2 [L]

也许存在更好的解决方案。你有个想法吗?

感谢

1 个答案:

答案 0 :(得分:0)

保持这样:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+ref\.php\?id=2[\s&] [NC]
RewriteRule ^ /boat? [R=302,L]

RewriteRule ^boat/?$ /ref.php?id=2 [L,QSA]