rewriterules conversion from .htaccess into IIRF (IIS6)

Topics: Developer Forum, User Forum
Nov 13, 2009 at 6:23 AM

 

     RewriteCond %{query_string} (&?opendocument&)([^&]+)
     RewriteRule ^(.*)$ /tmp/redir/%2? [L,R=301]
     RewriteCond %{request_uri} ^/tmp/redir/links [NC]
     RewriteRule ^links(.*)$ /tmp/redir/$1 [L,R=301]

     RewriteCond %{REQUEST_FILENAME}

 

!-d

     RewriteCondT %{REQUEST_FILENAME} !-f
     RewriteRule ^(.*)$ /tmp/redir/index.php?url=$1 [QSA,L]

Changing from .htaccess is a bit of a pain for one who's really not too bright (me) when it comes to coding.

I'm giving server some php-requests which it SHOULD interprete as file requests.

Requests to the server are in form of http://.../links?opendocument&XXXXXXXXXXXX and with this request it fetches the file location from a text file that is filled with filenames with full paths on the server. A problem is that the server DOES find the file and starts offering it for download BUT it keeps offering "links" as the filename even though it should be in offering me XXXXXXXXXXXX.dwg or YYYYYYYYYYYY.DOC. I see the filesize of the found file is correct so problem is not with the php but with rewrite.

Now this is from .htaccess where the example DOES work:

RewriteCond %{query_string} (&?opendocument&)([^&]+)

RewriteRule ^(.*)$ /%2? [L,R=301]

RewriteCond %{request_uri} ^/links [NC]

RewriteRule ^links(.*)$ /$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]

This cannot be used as IIRF.ini as is, but what all should I be changing in order to get things done?

 

Coordinator
Nov 13, 2009 at 6:50 AM

you can use this.  

RewriteCond %{query_string} (&?opendocument&)([^&]+)
RedirectRule ^(.*)$  /%2?  [R=301]

RewriteCond %{request_uri} ^/links [NC]
RedirectRule ^links(.*)$ /$1 [R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]

But in order for this to work, you need the DLL at http://iirf.codeplex.com/WorkItem/View.aspx?WorkItemId=25311

In IIRF, RewriteRule cannot redirect. You need to use RedirectRule.   

Nov 13, 2009 at 10:19 AM
Edited Nov 13, 2009 at 11:01 AM

I suppose I should use

RewriteRule ^(.*)$ /index.php?url=$1 [I,L]

instead of

RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]

right?

 

I used this RedirectRule and your new DLL but no help. Might IE6 and it's behavior have anything to do with this problem?

Coordinator
Nov 13, 2009 at 12:07 PM
slartsa wrote:

I suppose I should use

RewriteRule ^(.*)$ /index.php?url=$1 [I,L]

instead of

RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]

right?

Yes.  and No.  The QSA modifier is ok to use in IIRF.   But the rule that uses QSA is sort of broken, now that I look at it.  It doesn't make sense.  QSA says "append the query string in the original URL request to the query string in the replacement."   But you already append the entire URL to the query string in the replacement.  (url=$1).  So it makes no sense to use QSA.  But also, the [I] modifier tells IIRF to use case-insensitive matching when applying the pattern.  But you have no upper-case or lower-case characters in the pattern, so [I] is meaningless.   so I think you need only [L] .

slartsa wrote:

I used this RedirectRule and your new DLL but no help. Might IE6 and it's behavior have anything to do with this problem?

 No.  if you are seeing results you don't like, or don't understand, I would start by looking in the IIRF log file.