Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a PHP site running on IIS7 and I need to add some URL rewriting, but so far it seems to be ignoring my rule. Here's the rule:

<rewrite>
    <rules>
        <rule name="VCard" stopProcessing="true">
            <match url="\?user=(.*)$" />
            <action type="Rewrite" url="http://www.otherserver.com/vcard.aspx?user={R:1}" redirectType="Permanent" appendQueryString="false" logRewrittenUrl="true" />
        </rule>
    </rules>
</rewrite>

When using the UI to test my regex, it says that http://www.myserver.com/?user=123456 does match the rule, and that R:1 is "123456". But when I try to access the actual url it doesn't appear to work.

The logging doesn't seem too helpful:

2010-10-26 14:22:07 XXX.XXX.XXX.XXX GET / user=12345 80 - XXX.XXX.XXX.XXX Mozilla/5.0 (Windows;+U;+Windows+NT+6.1;+en-US)+AppleWebKit/534.10 (KHTML,+like+Gecko)+Chrome/8.0.552.11+Safari/534.10 200 0 0 187

As I mentioned above, the site itself is in PHP (which I'm less familiar with hosting on IIS). Could that be preventing the rewriting module from running? Am I missing a critical step somewhere?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The url match is for just the URL before the querystring, like folder/vcard.aspx.

It's probably a condition for {QUERY_STRING} that you need instead. Set .* for the url if you want to catch everything. Just be careful you don't run into a loop for that query.

This may be helpful: http://weblogs.asp.net/owscott/archive/2010/04/20/url-parts-available-to-url-rewrite-rules.aspx

It shouldn't matter that it's PHP. The redirecting occurs before it processes PHP.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.