User friendly URL does not work the way I need it

Asked

Viewed 123 times

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 I would have to do is when I access /imprensa he would have to upload the file imprensa.php now if you access it this way /imprensa/postagem-teste

he would have to upload the file ler-impresso.php passing the text postagem-teste in the variable p

someone knows where I’m going wrong ?

  • Here works normally, could explain which error exactly occurs?

  • when access meusite.com.br/press it loads the press file.php but when access meusite.com.br/press/post title it loads the same press file.php and not the read-printed file.php

  • Is it not the cache or something? In localhost the same problem occurs? Check whether you have uploaded correctly.

  • See if it helps Search Friendly Urls | Instant . htaccess Generator http://searchfriendlyurls.com/

1 answer

0

I did a test and I got it this way:

# 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]

Browser other questions tagged

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