Resolution:
Your rule:
rewrite ^/artista/([a-z]+) /artista.php?artista=$1 last;
You are redirecting the URL:
meusite.com.br/artista/nomedoartista
To remove the /artista/
snippet from the URL, simply remove it from the
rewrite ^([a-z]+) /artista.php?artista=$1 last;
Another observation in your rule, more specifically in the regular expression is that [a-z]
only searches for letters from a
to z
. (I'm not sure if it's case sensitive )
In the documentation examples use (.*)
which means any character, but I'd advise using [\w\-_]+
or [a-zA-Z0-9\-_]+
that takes alphanumeric characters (uppercase and lowercase), numbers, dash (-) and underscore (_):
rewrite ^([\w\-_]+)/?$ /artista.php?artista=$1 last;
Note: The /?
excerpt means that there may or may not be a /
bar at the end.
The rule to get the URLs with the other parameters would be:
rewrite ^([\w\-_]+)/([\w\-_]+)/?$ /artista.php?artista=$1&info=$2 last;
// $artista $info
//meusite.com.br/nome-do-artista/discografia
//meusite.com.br/nome-do-artista/musicas
//meusite.com.br/nome-do-artista/informacoes
Note: I've never worked with Ngnix, the examples posted here were based only on regular expressions (which I believe are the same for Apache mod_rewrite and Ngnix), have not validated, nor tested module syntax rewrite of Ngnix.
Related
Friendly URL using HTACCESS
Problem with form (GET method) and Friendly URL