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 snippet /artista/
of the URL, just delete it from the rule
rewrite ^([a-z]+) /artista.php?artista=$1 last;
Another remark in his rule, more specifically in the regular expression, is that [a-z]
search only letters of a
à z
. (I’m not so sure it is either case sensitive)
In the documentation the examples use (.*)
which means any character, but I advise using [\w\-_]+
or [a-zA-Z0-9\-_]+
which takes alphanumeric characters (upper and lower case), numbers, dash (-) and underscore (_):
rewrite ^([\w\-_]+)/?$ /artista.php?artista=$1 last;
Obs.: The excerpt /?
means there may or may not be a bar /
in 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 have 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), not Validei, nor tested the syntax of the module rewrite ngnix.
Related
User-friendly URL using HTACCESS
Problem with form (GET method) and URL Friendly
This rule is rewriting this URL
meusite.com.br/artista/nome-do-artista
, Isn’t that what you want? Nginx is the equivalent of Apache?– KaduAmaral
@Kaduamaral exactly, Nginx is similar to Apache. The way this rule stands, it works perfectly for the case
meusite.com.br/artista/joao
, but I would like to change tomeusite.com.br/joao
– Ricardo
So just take the part
/artista/
of the @Ricardo rule. ;)– KaduAmaral
You must specify the CSS path from the base of the URL using the slider
/
, example/css/meucss.css
or using the absolute URLmeusite.com.br/css/meucss.css
. For more details please read the comments of this reply.– KaduAmaral
@Kaduamaral, thanks! I will test here
– Ricardo