Problem with regular expression in . htaccess

Asked

Viewed 62 times

1

I have the following URL:

 http://< site >/restrito/usuarios/pagina/

This page is responsible for displaying a table containing users registered in the system, can receive as variable numbers to indicate the table page, since I show only values of 20 in 20.

The regular expression that solved my problem was the following:

RewriteRule ^restrito/usuarios/pagina/([^/.]+) restrito/usuarios.php?pagina=$1 [L]

The problem is that when I use $ to indicate that the ER ends there I get Error 404, and it happens with all the other rules of my .htaccess.

Someone would have the solution to this problem?

  • Utilizes $ where? In the URL or regex?

  • in regex itself, the url should look like this "http://< site >/restrict/usuarios/pagina/10" if the page is 10, for example, in fact only draws my attention because for the little I know of regular expression, to end the ER uses $ and always when I make use of it, get error 404

  • I still can’t understand, you mean the problem occurs when you do this RewriteRule ^restrito/usuarios/pagina/([^/.]+)$?

  • Exactly that @Guilhermenascimento

  • I’ll test here and as soon as I can edit the answer ;)

  • Quiet, if you want I can copy the whole file . htaccess here, as well as explain how the directory of the site

  • Copy it whole here please, it must be conflict with another rule

  • <Ifmodule mod_rewrite. c> Rewriteengine On Rewritecond %{REQUEST_FILENAME} ! -f Rewritecond %{REQUEST_FILENAME} ! -d Rewriterule ([ .]+)$ $1.php [NC,L] Rewriterule restrito/ver/usuario/([ /.]+) restrito/ver/usuario.php? id=$1 [NC,L] Rewriterule restrito/usuarios/pagina/([ /.]+) restrito/usuarios.php? pagina=$1 [L] Rewriterule restrito/Edit/usuario/([ /.]+) restricted/Edit/user.php? id=$1 [NC,L] </Ifmodule> - The first Rule is so I can ignore the . php of the files

Show 3 more comments

1 answer

0

If you’re trying to pass a querystring in the rewritten URL as an example:

http://< site >/restrito/usuarios/pagina/exemplo?foo=$

Then you might have to add the flag QSA

RewriteRule ^restrito/usuarios/pagina/([^/.]+) restrito/usuarios.php?pagina=$1 [L,QSA]

Browser other questions tagged

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