Jackymamouth
Jackymamouth

Reputation: 149

Rewrite rule with two $_GET

My .htaccess file is:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /art/art.php?galerie=$1

So thanks to this I can access the different galeries that exist : website.com/art/sun or website.com/art/beach for example ( as long as the galerie exists otherwise returns a error message saying page doesn't exists)

This all works fine up to here .

But i needed to add a $_Get on the page also : website.com/sun?row=2 for example.

But i cannot do this as sun?row=2 isn't a registered galerie ... How do I get around this problem ?

Upvotes: 1

Views: 15

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use the QSA (Query String Append) flag to forword new query strings to the target :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /art/art.php?galerie=$1 [QSA]

Now This will rewrite

  • /foo?querystring

to

/art/art.php?galerie=foo&querystring

Upvotes: 1

Related Questions