Friendly URL does not work the way I need it

0

I have the following htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^imprensa/?$ imprensa.php [NC,L]
  RewriteRule ^imprensa/([a-z0-9\-]+)/?$ ler-impresso.php?p=$1 [NC]
</IfModule>

What you would have to do is that when you access /imprensa it would have to load the file imprensa.php now if you access it /imprensa/postagem-teste

It would have to load the file ler-impresso.php passing the text postagem-teste into the variable p

Does anyone know where I'm going wrong?

    
asked by anonymous 12.04.2017 / 20:49

1 answer

0

I did a test and got it as follows:

# imprensa
RewriteRule ^(imprensa)$ imprensa.php [NC,L]
# imprensa/teste
RewriteRule ^(imprensa)/(.*?)$ ler-imprensa.php?p=$2 [NC,L]

Or if you want to use with ID in the URL:

# imprensa/123/teste
RewriteRule ^(imprensa)/([0-9]+)/(.*?)$ ler-imprensa.php?id=$2&p=$3 [NC,L]
    
13.04.2017 / 21:15