3

I am using this .htaccess code for my web application, It's working fine but i am unable to access $_GET variables.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule ^(.*)/(.*)/(.*)/$ index.php?$1&p=$2&id=$3 [L]
RewriteRule ^(.*)/(.*)/$ index.php?$1&p=$2 [L]
RewriteRule ^(.*)/$ index.php?$1

The URL i use right now is http://www.website.com/mainpage/subpage/id/ But if i do something like this http://www.website.com/mainpage/subpage/id/?template=new I cannot access the $_GET['template'] variable, I am pretty sure htaccess is causing this but i don't know how to proceed forward.

1 Answer 1

3

You need to add the QSA flag so that query strings get appended to the end of your rewrite targets:

RewriteRule ^(.*)/(.*)/(.*)/$ index.php?$1&p=$2&id=$3 [L,QSA]
RewriteRule ^(.*)/(.*)/$ index.php?$1&p=$2 [L,QSA]
RewriteRule ^(.*)/$ index.php?$1 [L,QSA]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.