How to recover everything after the "?" in Rewriterule?

Asked

Viewed 65 times

0

I have the following rule that was created by another programmer and that is running in some processes:

RewriteRule ^chk-error/(.*) chk_err.php?error=$1 [L]

She recovers everything that comes after chk-error/ and places within error to be treated within the archive chk_err.php. Works normally.

But I’ll need to use the same page chk_err.php and the URL that will access this path will come with a question mark. So:

https://www.example.com/chk-error/?errcat=5&errcd=514&id=12&in=gt5

I would like to adapt so that she can recover everything that comes after the interrogation "?". Without breaking the previous process.

What would the new Rewriterule with the "?" being optional?

In short I wanted to rewrite the Rewriterule that is working to recover that URL:

https://www.example.com/chk-error/errcat=5&errcd=514&id=12&in=gt5

In order to recover this other URL pattern:

https://www.example.com/chk-error/?errcat=5&errcd=514&id=12&in=gt5

Note that the difference between them is only the question mark "?" after chk-error/ .

  • 1

    I don’t understand the question. $_GET does not answer?

  • Hi Felipe I improved the question. When I use GET the variable error comes empty. What it seems that the regex is not picking up everything after chk-error/?. But if I remove the interrogation everything works.

2 answers

-2

Is this the only rule that the URL passes? If I understand correctly, just deny the symbol ? in the rule and everything should work out as you want.

RewriteRule ^chk-error/(^?.*) chk_err.php?error=$1 [L]

-2

The flag must be used [QSA] (Query String Append) to pass the url parameters.

Source

Browser other questions tagged

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