How do I redirect a nonexistent url through htaccess?

0

I need to redirect the following link:

http://dominio.com/receitas-user/ID_do_usuario/nome_do_usuario

To:

http://dominio.com/receitas/author/nome_do_usuario

Being nome_do_usuario and ID_do_usuario two variables.

I tried to do this but it did not work:

RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} ^/receitas-user/([0-9-a-z\-]+)/([0-9-a-z\-]+)$ [NC]
RewriteRule ^(.*)$ http://dominio.com/receitas/author/%2? [R=301,L]
    
asked by anonymous 18.04.2017 / 18:22

1 answer

0

It seems like this is wrong %2 . The match should be with dollar sign, thus $2

It should look like this:

RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} ^/receitas-user/([0-9-a-z\-]+)/([0-9-a-z\-]+)$ [NC]
RewriteRule ^(.*)$ http://dominio.com/receitas/author/$2? [R=301,L]
    
18.04.2017 / 18:28