Scooter5150
Scooter5150

Reputation: 167

htaccess specify path for file

I'm trying to create a RewriteRule in an .htaccess file where, when a user tries to access: mp.php?id=2 the URL is rewritten to /private/items/mp.php?id=2

I tried different variations, based on this page: http://corz.org/serv/tricks/htaccess2.php The most recent of which is:

RewriteRule ^mp.php/(.*) /%1/private/items/mp.php?id=$1 [QSA]

Which, doesn't appear to work, although, I think I'm missing something.

Upvotes: 1

Views: 82

Answers (1)

Arnaud Le Blanc
Arnaud Le Blanc

Reputation: 99921

RewriteRule does not match in query strings, and can copy the query string to the rewriten path, so you only have to do this:

RewriteRule ^mp\.php /private/items/mp.php [QSA]

Which will result in mp.php?id=42 being rewritten to /private/items/mp.php?id=42

Upvotes: 1

Related Questions