0

I have gone through a lot of tutorials on apache,and could redirect few urls. Though,there is this url for which I need to do a redirect and I couldn't.Any help would be much appreciated! Thanks ! Note: Making changes to httpd.conf

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

As I have already configured my domain, Just need to redirect URL : /common/webScript.jsp?path=/example/content/latest.rss?section=Insight%26type=Leaders to /

1 Answers1

0

uri-path after "?" character are query strings, you need to check them with %{QUERY_STRING} ^path` or similar. Rough example:

# 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]

If you just want to redirect /common/webScript.jsp to / just do a simple:

RedirectMatch ^/common/webScript.jsp /
Daniel Ferradal
  • 2,727
  • 1
  • 13
  • 19
  • Great ! Thanks ! But I dont want to identify url with query string "path" but wanted to identify if the url starts with /common/webScript.jsp. If the url starts with /common/webScript.jsp ,wanted to redirect to / – Shailaja Krishnamurthy Aug 08 '17 at 08:35
  • @ShailajaKrishnamurthy added a new option based on your comment. – Daniel Ferradal Aug 08 '17 at 08:39
  • HI @ezra-s , this is working fine ! Thanks !But in addition to the RewriteCond ,used RewriteRule and not RedirectMatch and it worked fine! – Shailaja Krishnamurthy Aug 08 '17 at 09:02
  • Use RewriteCond when you have a real condition you want to check and can only be done with RewriteCond, like for example, checking query string. Using RewriteCond and RewriteRule to redirect a simple uri-path is overkill. – Daniel Ferradal Aug 09 '17 at 10:16