Rewrite .HtAccess rewrite to IIS challenge

Craig Lambie
Craig Lambie used Ask the Experts™
on
Hi Experts,

I have a challenge for you... I need to convert the follow .htaccess rewrite rules to work on an IIS Server.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule file/.* s3url.php [NC,L]

Can you help?
I am thinking something like
 
<rewrite>
      <rules>
				<rule name="wordpress" patternSyntax="Wildcard">
					<match url="*" />
						<conditions>
							<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
							<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
						</conditions>
					<action type="Rewrite" url="index.php" />
				</rule>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="file/.*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="s3url.php" />
                </rule></rules>
    </rewrite>

Open in new window

But that doesn't work.

Thoughts?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004

Commented:
The first rule will pick up all URLs, causing the second rule to never fire.  Reverse the order of execution.

Author

Commented:
I tried that.
Still no joy :(
Thoughts?
Top Expert 2004

Commented:
Explain how it is not working.  Have you tried to monitor the request with tracing?
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Author

Commented:
Ok.
If you go to this page http://truesecrets.com.au/test-page/ and click "download file" the program called s3flowshield is using URL rewrite rules, that they only support in a linux environment, to rewrite the URL into some AmazonS3 protected environment file.

What I need is to make this work in IIS.
I don't know how to monitor the request with tracing.
Top Expert 2004

Commented:
In your rewrites, try removing the ignoreCase attributes from your conditions.  Windows is not naturally case-sensitive, though Linux is.  

To monitor failed request tracing, you will need to set it up for that site.  See these two URLs for more information on configuring it:

http://learn.iis.net/page.aspx/488/using-failed-request-tracing-rules-to-troubleshoot-application-request-routing-arr/
http://technet.microsoft.com/en-us/library/cc731798%28WS.10%29.aspx

Once you have FRT enabled, browse to the failing URL.  This will generate a file in the tracing directory you provided during configuration.  Upload that file here as an attachment, and we will see what the rewrite module is doing.

Author

Commented:
Ok, I tried removing the case sensitivities.
 
<rules>
			<rule name="Imported Rule 1" stopProcessing="true">
				<match url="file/.*" />
				<conditions logicalGrouping="MatchAll">
					<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="true" negate="true" />
					<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="true" negate="true" />
				</conditions>
				<action type="Rewrite" url="s3url.php" />
			</rule>
			<rule name="wordpress" patternSyntax="Wildcard">
				<match url="*" />
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
					</conditions>
				<action type="Rewrite" url="index.php" />
			</rule>
		</rules>

Open in new window

No luck.

I am going to try this FRT, will let you know.

Author

Commented:
I have had to setup an entire IIS copy of the system on my local machine, which I hope duplicates the environment a fairly closely (Can't do it on Live server)
Here is the FRT file  fr000002.xml

Thoughts?
Top Expert 2004
Commented:
Looking at the FRT file, the first rule "Imported Rule 1" is doing exactly what it is supposed to.  It matched the request, identifies as "not a file/not a directory", rewrites the request, and stops rewrite processing.  The end result is the request going to /s3url.php.  Examine steps 111-120 in the file (it helps if you use the xsl file for styling).

What behavior did you expect?  Be very specific, please.

Author

Commented:
Hi

I have to close this, the company that developed the s3url.php won't login and respond with what is supposed to happen.
I warn other users of s3flowshield away from using this software.  I highly recommend using s2Member plugin for Wordpress instead.

Thanks all for contributing to this post.
I will allocate points accordingly.

C

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial