php - Rewrite directorys to file and after ? variables

251

I have this Apache rewrite code in my .htaccess file:

RewriteEngine on
RewriteRule ^main\/(.*) /parser.php?folders=$1

But I can't access the request parameters after?. For example,

htttp://example.com/main/directry/directory2/?variable=1&error=0

How can i access those variables? I use PHP.

555

Answer

Solution:

You just needQSA flag in your rule:

RewriteEngine on
RewriteRule ^main/(.*)$ /parser.php?folders=$1 [L,QSA,NC]
  • QSA (Query String Append) flag preserves existing query parameters while adding a new one.

People are also looking for solutions to the problem: javascript - Uncaught ReferenceError: ajaxObj is not defined

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.