301岁的参数名称重定向到新的htaccess的参数名称 [英] 301 redirect old parameter names to new parameter names by htaccess

查看:136
本文介绍了301岁的参数名称重定向到新的htaccess的参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是改变了两个参数名称和想重定向旧名称来改变名称的人,在任何地方URL的任何值。例如:

I just changed two parameter names and wanna redirect old names to changed name ones with any values anywhere in URL. e.g:

product.php?colornew=anyvalue&productname=anyvalue

301重定向:

301 redirect to:

product.php?color=anyvalue&product=anyvalue

请注意,这只是一个例子,正如我所说的这两个参数可以与任何价值网址在任何地方。

Please note that this is just an example and as I said these two parameter can be anywhere in URL with any value.

推荐答案

您可以使用此code中的任何URL重命名您的查询参数:

You can use this code to rename your query parameters in any URL:

RewriteEngine On

# rename query parameter colornew=>color
RewriteCond %{QUERY_STRING} ^(.*&)?colornew=([^&]*)(&.*)?$ [NC]
RewriteRule ^ %{REQUEST_URI}?%1color=%2%3 [NC]

# rename query parameter productname=>product
RewriteCond %{QUERY_STRING} ^(.*&)?productname=([^&]*)(&.*)?$ [NC]
RewriteRule ^ %{REQUEST_URI}?%1product=%2%3 [NC,NE,L,R=302]

这篇关于301岁的参数名称重定向到新的htaccess的参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆