1

I am having some trouble redirecting some old URLs to new ones.

This is the old path:

/index.php?loadpage=./includes/search.php&searchstring=KEYWORD

and I want it to redirect to this URL:

/search/node/KEYWORD

*where "KEYWORD" is a variable search string.

This is what I have tried so far:

RewriteRule ^/?search/node/([^/d]+)/?$ index.php?loadpage=./includes/search.php&searchstring=$1 [L,QSA]

and this:

RewriteRule ^/?search/node/([^/d]+)/?$ index.php?searchstring=$1 [L,QSA]

but the redirects don't work.

Can anyone please help or give me some guidance on how to fix these redirects?

Thank you in advance!

consuela
  • 115
  • 8

1 Answers1

1

This should work :

RewriteCond %{QUERY_STRING} &searchstring=([^&]+) [NC]
RewriteRule ^index\.php$ /search/node/%1? [R=301,L]

Basically, first search for the searchstring parameter in query string.

The searching parameter value is put in a variable called %1

Then replace index.php with /search/node/%1


E.g :

From this :

http://domain.com/index.php?loadpage=./includes/search.php&searchstring=KEYWORD

I am redirected to this :

http://domain.com/search/node/KEYWORD

From this :

http://domain.com/index.php?loadpage=./includes/search.php&searchstring=SERVERFAULT

I am redirected to this :

http://domain.com/search/node/SERVERFAULT

Seems ok (hope) ! :)

krisFR
  • 12,830
  • 3
  • 31
  • 40