通过apache重定向URL

时间:2017-08-03 08:55:44

标签: apache url-redirection httpd.conf

我已经阅读了很多关于apache的教程,并且可以重定向几个网址。 虽然,有这个网址,我需要做一个重定向,我不能。任何帮助将不胜感激!谢谢 ! 注意:更改httpd.conf

网址:https://example.com/common/webScript.jsp?path=/example/content/latest.rss?section=Insight%26type=Leaders  到https://example.com

由于我已经配置了域名,只需要重定向即可 网址: /common/webScript.jsp?path=/example/content/latest.rss?section=Insight%26type=Leaders 至/

1 个答案:

答案 0 :(得分:0)

uri-path"?"字符是查询字符串,您需要使用%{QUERY_STRING} ^ path`或类似字符进行检查。粗略的例子:

# to capture uri-path with query string starting with "path..." 
# redirect it to /

# for 2.4 with If directive (most modern)
<If "%{QUERY_STRING} =~ m#^path#">
    RedirectMatch ^ /
</If>


# or with mod_rewrite that works with 2.2 too    
RewriteEngine on
RewriteCond %{QUERY_STRING} ^path
RewriteRule ^ / [R,L,QSD]

如果您只想将/common/webScript.jsp重定向到/ 做一个简单的事:

RedirectMatch ^/common/webScript.jsp /