[ 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
Answer 1
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.