mod-rewrite - 用参数来新的URL重定向URL [英] Mod rewrite - redirecting url with parameter to new url
问题描述
我需要一些帮助与重定向特定参数值的URL到新的URL。例如如何我这两个网址,ID为123和345重定向到一个新的网址是什么?
I need some help redirecting a url with particular parameter value to a new url. For example how can i redirect these two urls with id 123 and 345 to a new url?
重定向
http://testserver.xyz.com/abc/content/ content.jsp?内容ID = 123
http://testserver.xyz.com/abc/content/content.jsp?contentId=345
http://testserver.xyz.com/abc/content/content.jsp?contentId=123 http://testserver.xyz.com/abc/content/content.jsp?contentId=345
到
任何帮助将大大AP preciated
Any help will be greatly appreciated
TIA
推荐答案
使用mod_rewrite,加入或者您的htaccess文件这些规则在你的文档根目录,或者您的虚拟主机/服务器配置:
Using mod_rewrite, add these rules in either your htaccess file in your document root, or your vhost/server config:
RewriteEngine On
RewriteCond %{QUERY_STRING} contentId=123 [OR]
# add however any more id's here, with `[OR]` flags
RewriteCond %{QUERY_STRING} contentId=345
RewriteRule ^/?abc/content/content\.jsp$ https://newpage.silkroad.com/? [L,R=301]
这篇关于mod-rewrite - 用参数来新的URL重定向URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!