2

I have a url like this:

 http://mydomain.es/foro.php?topic=9

And I want to redirect it to:

 http://mydomain.es/foro/9/

But I can't get it to work, I have tried something like:

 redirectMatch  302 ^/foro.php\?topic=([0-9]+)$ /foro/$1/

But it don't work, the problem is the character ?, if i remove it in the url (and use a redirectMarch like

 redirectMatch  302 ^/foro.phptopic=([0-9]+)$ /foro/$1/) 

it works fine, can you help me? I'm going crazy.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
MacFresno
  • 58
  • 4

2 Answers2

0

answered here - query strings are not supported by rewritematch. Use mod_rewrite instead.

Community
  • 1
  • 1
Alexander Balabin
  • 2,055
  • 11
  • 13
0

This should work :

 RewriteEngine On
 RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?foro\.php\?topic=([^&\s]+) [NC]
 RewriteRule ^ /foro/%1? [NE,NC,R,L]

RewriteRule ^([^/]+)/([^/]+)/?$ /foro.php?topic=$2 [QSA,NC,L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115