3
I’m trying to make the Urls on my site friendly.
URL friendly
http://localhost/mg/artista/10
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^/artista/([0-9]+)$ /artista.php?artista=$1
</IfModule>
PHP to retrieve variable
$artista = $_GET['artista'];
You are giving the following error: Notice: Undefined index: artist
I saw in some places people recovering the variable using $_SERVER['REQUEST_URI']. If I use this, it returns me: /mg/artist/10. I could take the variable, but I don’t know if this is the right way.
thanks for the tool tip, I didn’t know. I took the " /" and the error remained the same. Is the error not in the variable recovery? Abs
– Ricardo
I saw in some places people recovering the variable using $_SERVER['REQUEST_URI']. If I use this, it returns me: /mg/artist/10. I could take the variable, but I don’t know if this is the right way.
– Ricardo
@Ricardo Try to take the
/
beforeartista
and see if it works for you.– André Ribeiro
@Andréribeiro The problem may be
$
at the end of the expression it was not enough just to remove^
from the beginning. So it seems to work:RewriteRule /artista/([0-9]+) /artista.php?artista=$1
.– stderr
@Andréribeiro did not help to take the /
– Ricardo
@Qmechanic73, also not working
– Ricardo
Thinking that the error is not in . htaccess but in variable recovery...
– Ricardo
@So Ricardo is some problem with his apache.
– André Ribeiro