1

I'm trying to redirect from /index.php?option=com_k2&view=itemlist&task=category&id=44:pinco to google.it

Note the special char :

But it doesn't seem to work.

This is one of the tests I've tried. Where am I wrong?

redirect 301 /?option=com_k2&view=item&id=44:pinco http://www.google.it
Revious
  • 7,816
  • 31
  • 98
  • 147
  • _“Where am I wrong?”_ - in your understanding of what the documentation means when it says _“URL-path”_ ... – CBroe Dec 06 '17 at 14:43
  • @CBroe: do you mean that the path should be absolute? – Revious Dec 06 '17 at 14:44
  • Or that it's not possible to parse the entire query string? – Revious Dec 06 '17 at 14:45
  • 2
    The _path_ component of the URL is the only thing that gets checked against here - and that is just `index.php`. If you want to do anything based on the query string, then you need to use mod_rewrite (RewriteCond to check query string contents, followed by a RewriteRule to then redirect elsewhere based on the condition.) – CBroe Dec 06 '17 at 14:49
  • @CBroe: thanks. But how can I achieve it with the Rewrite? – Revious Dec 06 '17 at 14:53
  • 1
    Possible duplicate of [How to redirect URLs based on query string?](https://stackoverflow.com/questions/13073253/how-to-redirect-urls-based-on-query-string) – CBroe Dec 06 '17 at 14:54

1 Answers1

1

You can not redirect Query String using Redirect directive. You need to check Query String using ℅{QUERY_STRING} variable.

RewriteEngine on

RewriteCond ℅{QUERY_STRING} ^option=com_k2&view=itemlist&task=category&id=44:pinco$
RewriteRule ^index\.php$ http://google.it? [L,R]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115