Redirect search query urls to new url structure

69 views Asked by At

I have changed the platform of my site and therefore have a new search url structure.

The old url structure is like this:

/catalogsearch/result/?q=test

and the new url structure is like this:

/search_results.php?keyword=test&submit_search=

I have tried to redirect the old URLs to the new one using this code, but it doesnt appear to be working.

RewriteRule ^(catalogsearch\/result\/\?q=).*$ search_results.php?keyword=$1&submit_search= [L]

Is there something I am missing?

1

There are 1 answers

0
anubhava On

You need to use RewriteCond %{QUERY_STRING} to match query string.

You can use:

RewriteCond %{QUERY_STRING} ^q=([^&]*)$ [NC]
RewriteRule ^catalogsearch/result/?$ search_results.php?keyword=%1&submit_search= [L]