user3790467
user3790467

Reputation: 27

RewriteRule pass along query string

I'm trying to make a system, so when you visit the link about.php it will make it seem like you go through index.php?page=about

I did this using htaccess file.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !index.php [NC]
RewriteRule ^(.*)\.php$ index.php?page=$1 [NC]

My problem is that if i access fx about.php?avar=set this does not pass through. I simply dont know much about htaccess files or how to set this up.

Upvotes: 1

Views: 66

Answers (1)

anubhava
anubhava

Reputation: 784958

Have your rule add QSA and L flags:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
RewriteRule ^(.+?)\.php$ index.php?page=$1 [L,QSA]

QSA (Query String Append) flag preserves existing query parameters while adding a new one.

Upvotes: 1

Related Questions