Hi, how can i redirect index.php?search= to the base url? I tried it with this code:
redirectMatch 301 ^/index.php?search=(.*) http://www.yoursite.com/
but then the page loops the code if i enter the site domain..
Hi, how can i redirect index.php?search= to the base url? I tried it with this code:
redirectMatch 301 ^/index.php?search=(.*) http://www.yoursite.com/
but then the page loops the code if i enter the site domain..
Try:
RedirectMatch permanent ^/index.php?search=(.*)$ http://www.yoursite.com/
mod_alias does only work on the URL path and not the query:
mod_alias is designed to handle simple URL manipulation tasks. For more complicated tasks such as manipulating the query string, use the tools provided by mod_rewrite.
So try mod_rewrite instead:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^search=(.*)
RewriteRule ^/index\.php$ /? [L,R=301]
Or more general:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^([^&]*&+)*search=([^&]*)
RewriteRule ^/index\.php$ /? [L,R=301]
And if you want to use this rule the .htaccess file in your root directory, remove the leading slash from the patterns.