I have this in URL
/search/?query=anything
and I need this
/search/anything/
where "anything" is any thing in URL after. So all I want is to cut out this part
?query=
from the middle of the URL. How?
CodePudding user response:
This probably is what you are looking for:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^query=(. )$
RewriteRule ^/?search/?$ /search/%1 [R=301,QSD,L]
RewriteRule ^/?search/(. )/?$ /search/?query=$1 [L]
CodePudding user response:
This is a decision that my hosting provided:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^query=(.*)$ [NC]
RewriteRule ^/?search/?$ /search/%1 [R=301,L]
RewriteRule ^/?search/(. )/?$ /search/?query=$1