开发者

Problems using URL Rewrite in IIS7 for friendly URLs

I'm trying to make some rewrite rules in my IIS7 server using URL Rewrite. For example, I have the url mydomain.com/data.php?id=1 and I want to convert it to 开发者_运维问答mydomain.com/archive/1

Currently I have:

    <rule name="Ugly to friendly" stopProcessing="true">
  <match url="^data\.php$" />
  <conditions>
      <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
      <add input="{QUERY_STRING}" pattern="^([^=&amp;]+)=([^=&amp;]+)$" />
  </conditions>
  <action type="Redirect" url="archive/{C:2}" appendQueryString="false" /> 
</rule>

<rule name="Friendly to ugly" stopProcessing="true">
  <match url="archive/(.+)" />
  <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  </conditions>
  <action type="Rewrite" url="data.php?id={R:1}" />
</rule>

but it doesn't work (read as "page shows fine without that rule, but when rule is added no css/imgs are shown). Weird, as firebug tells me that everything is ok (200 OK) (maybe it gets confused too?)

Regards


Sorry, the code is just fine. My page (data.php) is wrong. Instead of having all imgs/css using relative paths from the php file, I should have wrote those using relative paths from the root.

I mean, instead of "img src="../../test.jpg" I should have wrote "img src="/folder1/fol".

Note the "/" at the beggining of the path.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜