madkeen
madkeen

Reputation: 97

Rewrite URL to hide query string

I'm trying to mask the query string of my pages in order to hide it's unique page ID. This is important as each ID needs to be unique to a user.

Currently the URL structure looks like this:

http://domain.com/page.php?Page_ID=1234
(where 1234 is any number)

but I need it to look like this:

http://domain.com/page.php

I have tried adding the following to the .htaccess file but it does not seem to make any difference:

RewriteEngine on
RewriteBase /
RewriteRule ^page.php?Page_ID=([0-9]+)/$ page.php [L,QSA,NC]

I've looked at other posts like this one and others, but can't seem to find a solution. Is there something I might be missing here?

Upvotes: 3

Views: 1636

Answers (1)

Amit Verma
Amit Verma

Reputation: 41249

Query string is not part of match in rewrite rule, you need to match against %{THE_REQUEST} using a rewriteCond

RewriteEngine on


RewriteCond %{THE_REQUEST} /page\.php\?page_ID=.+ [NC]
RewriteRule ^ %{REQUEST_URI}? [L,R]

Upvotes: 3

Related Questions