Amr SubZero
Amr SubZero

Reputation: 1276

#HTACCESS hide multi PHP GET tag from the URL

i'm replacing this

localhost/load.php?code=foo

with this

localhost/foo

using this htaccess code

RewriteRule ^(\w+)$ ./load.php?code=$1

works pretty good! but what about including other get tag in the same URL like

localhost/load.php?user=foo&code=foo

replaced it with htaccess to be like

RewriteRule ^(\w+)$ ./load.php?user=$1&code=$1

but doesn't work as well! so what is the correct htaccess code to do this?

Upvotes: 1

Views: 293

Answers (1)

Halcyon
Halcyon

Reputation: 57729

Depending on your other RewriteRules you might want to use a catch-all rule with the QSA (QueryStringAppend) flag.

The QueryString is the part after ? so user=foo&code=foo.

If you have a rule that says:

RewriteRule ^(.*)$ load.php?__path=$1 [QSA]

And you call:

my.domain.com/page/sub?foo=bar&baz=ipsum

load.php will get the following GET:

__path = page/sub
foo = bar
baz = ipsum

With a rule like this you can handle any URL.

Upvotes: 1

Related Questions