Sina Fathieh
Sina Fathieh

Reputation: 1725

url rewriting problem

I'm trying to map any request like /?page=pagename to this /html/pagename.html ( sort of opposite of what people normally do), so for example if the request was mydomain.com/?page=home then I want my server to return this file : /html/home.html I tried this rule, but gives my error 500 :

RewriteRule ?page=(.*) /html/$1.html [NC]

any idea folks ?

Upvotes: 2

Views: 38

Answers (1)

Dan Grossman
Dan Grossman

Reputation: 52372

Try this:

RewriteCond %{QUERY_STRING} page=(.*)
RewriteRule .* /html/%1.html [NC]

RewriteRule matches and rewrites only URIs. The query string (the stuff after the question mark) is not part of the URI, so it'll never match against a RewriteRule pattern. You have to use a RewriteCond to conditionally evaluate a rule (in this case, on every URI) when the query string matches something.

Upvotes: 2

Related Questions