How to redirect url with query with . htaccess?

Asked

Viewed 109 times

2

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

site/nossos-socios.php?termo=teste

for

site/nossos-socios/?q=teste

I need you to have the question before q=, I tried using the question escape, but it doesn’t 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]
  • 1

    Take a look here. You’ll probably have to use the %{QUERY_STRING} as quoted in the reply.

1 answer

1


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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.