开发者

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开发者_JS百科 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 ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜