How do I redirect a non-existent htaccess url?

Asked

Viewed 149 times

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 it this way but it didn’t 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]

1 answer

0

It seems that this is wrong %2. The match should be with dollar, so $2

Should stay 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]
  • Didn’t work :(

  • @free4k could give some detail? It is a bit confusing to understand what is occurring. Anyway I will test

  • I need to redirect this link http://mobiledev.ml/receitas-user/589/admin to http://mobiledev.ml/receitas/author/admin/ where admin is the user name and will always be different. Just didn’t work can access the link to be able to see better.

  • Ah got it, the redirect is not happening @free4k I will test on my machine and come back as soon as I finish.

Browser other questions tagged

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