IIS 7.0 URL Rewrite Module - Root URL doesn't

2019-07-27 00:20发布

I'm trying to setup a PHP website in IIS 7.0 with URL rewriting enabled using this module (http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1691)

I've got the whole thing running fine for inner pages of the site, but my root URL "/" doesn't work any more.

I want the structure of my URLs to be www.test.com/test-page.html and this is rewritten to www.test.com/index.php?page=test-page

The rule that I have specified is as follows:

Regular expression to match : ^([^/.]+)/?.html Rewrite to: /index.php?page={R:1}

as I said it works fine for all the inner pages so www.test.com/test-page.html would load no problem, it is just the homepage, www.test.com that doesn't work.

Any help would be much appreciated, I'm assuming that I need to add some sort of extra condition?

1条回答
We Are One
2楼-- · 2019-07-27 00:48

try ^(?:([^/.]+).html)?$

this will make the entire check for: 1 or many characters not / or not . followed by .html optional.

查看更多
登录 后发表回答