S.Lund
S.Lund

Reputation: 47

htaccess rewrite - probably simple

I'm looking for a way to rewrite my URLs and am checking what htaccess can do for me.

I want to rewrite

domain.com/index.php?page=myPage&name=test

to

domain.com/myPage/?name=test

All tutorials I've found only shows how to do complex things but something as simple as this, isn't to be found anywhere.

What I have only rewrites "myPage" to "page=myPage" and ignores what I put after "?" in my URL

RewriteRule ^([^/\.]+)?$ index.php?page=$1 [L]

Notice that "name=test" could be anything (id=1, mode=edit, foo=bar).

Upvotes: 0

Views: 28

Answers (1)

Stephen
Stephen

Reputation: 18917

Try adding the flag for "query string append" by changing [L] to [QSA,L]

Source: https://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_qsa

Upvotes: 1

Related Questions