HT访问重定向从PHP与参数失败


htaccess redirect for from php with parameters failing

我在以下重定向时遇到问题。

Redirect 302 /info/index.php?product=xxx http://xyz.com/xxx/

我不明白为什么它不起作用。 我必须转义角色吗?

不能使用Redirect指令来匹配查询字符串。请改用mod_rewrite

将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^product=([^&]+)
RewriteRule ^index'.php$ http://xyz.com/%1/? [L,NC,R=301]

参考:阿帕奇mod_rewrite简介