How to redirect url with query with .htaccess?

2

I have the following problem, I need to redirect the following url:

site/nossos-socios.php?termo=teste

for

site/nossos-socios/?q=teste

I need to have the interrogation before q =, I tried to use the escape with the interrogation, but it does not work.

Follow my .htaccess below, it redirects only to nossos-socios/q=aço :

RewriteRule ^nossos-socios/q\=([^/.]+)?$ nossos-socios.php?termo=$1 [NC,L]
    
asked by anonymous 28.04.2017 / 17:05

1 answer

1

I found the solution, it is necessary to use RewriteCond with a query string:

RewriteCond %{QUERY_STRING} ^q=([^&]+) [NC]
RewriteRule ^(nossos-socios)/?$ $1.php?termo=%1 [NC,L]
    
28.04.2017 / 23:21