【问题标题】:Mod rewrite - redirecting url with parameter to new urlMod rewrite - 将带有参数的 url 重定向到新的 url
【发布时间】:2012-09-24 06:18:07
【问题描述】:

我需要一些帮助,将具有特定参数值的 url 重定向到新 url。例如,我如何将这两个 id 为 123 和 345 的 url 重定向到一个新的 url?

重定向

http://testserver.xyz.com/abc/content/content.jsp?contentId=123 http://testserver.xyz.com/abc/content/content.jsp?contentId=345

https://newpage.silkroad.com/

任何帮助将不胜感激

TIA

【问题讨论】:

  • 请帮忙。我正处于时间紧迫的状态。

标签: mod-rewrite apache2


【解决方案1】:

使用 mod_rewrite,将这些规则添加到文档根目录中的 htaccess 文件或虚拟主机/服务器配置中:

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]

【讨论】:

  • 感谢乔恩·林。它工作得非常好,只是它重定向并将 contentId 添加到它重定向到的 url。例如:它重定向到newpage.silkroad.com/?contentId=abc 我该如何防止呢?非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-08
  • 1970-01-01
  • 2014-01-30
  • 2021-01-24
  • 2017-03-22
  • 2019-04-30
相关资源
最近更新 更多