IIRF.ini Script Help - Almost there

Jan 13, 2010 at 11:58 PM

Hey everyone,

 

Sorry for the n00b questions but i have been stuck trying to get the exact rewrite rule i need.  First I will explain what I need and then second show what I have done as i may be inefficient and the coding on this as well, so any response would be great.

  1. First Question: - Is there a way to trigger the Isapi rewrite only when it encounters the dynamicpage.cfm page?
    • Object: I have domain, www.domain.com and I am dynamically creating pages that i would like to show as a directory structure based on the given name i give it.
    • I currently have the format of http://www.domain.com/dynamicpage.cfm?url=Product-Name which i would like to show as http://www.domain.com/Product-Name
    • I am able to get it to work with the code below BUT I had to add to the .ini to ignore all the .css/.js/.jpg/.gif and so on.  
    • Also, as stated the page comes up but in the top left corner of the web page i see "url=Product-Name" without the quotes of course, what could be causing that?
  2. Second Question: - How should I setup my Iirf.ini file if i want to utilize a directory inside a directory like the following, http://www.domain.com/Category-Name/Product-Name or http://www.domain.com/Category-Name1/Category-Name2/Product-Name
  3. Third Question - How can I make sure the Isapi rewrite doesn't try to rewrite everything as i am only needing it to rewrite the dynamicpage.cfm URL.
    • Currently i can type this in the browser, http://www.domain.com/xxx and the rewrite shows a page similar to the dynamicpage.cfm with missing data like it is defaulting to a page and thee is not page or directory named 'xxx'.
  4. Fourth Question - How can I tell the isapi filter to ignore my coding variables, i use a variable application path which can't be found because the ISAPI filter is trying to filter the path.
    • The code is, <link href="#application.root_path#style.css" rel="stylesheet" type="text/css" /> as you can see application.root_path can't be found.

 

Here is the current Iirf.ini i have but obviously I could be doing this all wrong.  Thanks in advanced for the help.

RewriteCond %{HTTP_URL}             (/|\.css|\.js|\.html|\.jpg|\.gif|\.png|\.pdf|/[^.]*)$   [I]
RewriteCond %{REQUEST_FILENAME}     !-f
RewriteCond %{REQUEST_FILENAME}     !-d
RewriteRule ^/([^/]+)   /dynamicpage.cfm?url=$1


Coordinator
Jan 14, 2010 at 12:39 AM
Edited Jan 14, 2010 at 1:27 AM

I'll try to help.

> Is there a way to trigger the Isapi rewrite only when it encounters the dynamicpage.cfm page?

Yes, but reading further in your question, I don't think that's what you want. You want the external URL to NOT be dynamicpage.cfm .   The way URL Rewriting works:  the filter looks at the external URL request, and maps it to an internal URL.  If the dynamicpage.cfm is only intended to be used internally, and never exposed externally, then you cannot very well use it as input to a rule in the filter.

> I am able to get it to work with the code below BUT I had to add to the .ini to ignore all the .css/.js/.jpg/.gif and so on.

That sounds right.  there is no way for the filter to know that .jpg or .css etc, is not to be rewritten, unless you tell it so.

> the page comes up but in the top left corner of the web page i see "url=Product-Name" without the quotes of course, what could be causing that?

That is an error in your dynamicpage.cfm.  Maybe a debugging statement left in by accident.  IIRF won't generate or modify a response in any way.  The way you are using it, it only does URL mapping.

> Second Question:

You need to use capture groups to match on the particular parts.  for example

RewriteRule ^/([^/]+)/([^/]+)$    /dynamicpage.cfm?A=$1&B=$2

This will match only on URL paths with exactly two segments.

 > Third Question -... i am only needing it to rewrite the dynamicpage.cfm URL.

I really don't know how to answer that.  The Filter applies rules based on incoming URLs, not the outgoing URLs.  There is some way you must devise that distinguishes a URL that should be rewritten, from a URL that should not.  That job is yours.   What you have said so far is "I only want dynamicpage.cfm to be rewritten."  But this is not what you are doing.  You are rewriting FROM any URL, TO dynamicpage.cfm. 

> Currently i can type this in the browser, http://www.domain.com/xxx and the rewrite shows a page similar to the dynamicpage.cfm with missing data

Yes, exactly.  That is what your rule says the filter should do.  If there is some xxx that should not be rewritten, you need to tell the filter what that is, and exclude it.  You haven't articulated which incoming URLs should not be rewritten.

> Fourth Question - How can I tell the isapi filter to ignore my coding variables.  The code is, <link href="#application.root_path#style.css" rel="stylesheet" type="text/css" />

I don't know what that means.  I don't understand the question. 

> as you can see application.root_path can't be found.

No, I don't see that at all.  I don't understand the question.

 

Jan 14, 2010 at 12:59 AM

Cheeso,

 

First, I want to thank you for not only the support you give to this project but your time you spend on this board helping n00bs like me as isee your responses to a majority of these posts :).  Yes,  you are write, i think i incorrectly wrote the From and To.  I want the URL to show www.domain.com/product-name and map to www.domain.com/dynamicpage.cfm?url=product-name. 


The application.root_path reference is a path that I identify in my application.cfm (like web.config) file.  In this file i specify the domain path of the site so the dynamicpage.cfm has .css references as well as paths to my javascript.  I get errors stating that my element root_path is undefined even though it is defined in my application.cfm. 

Am I correct to assume that when i place extra characters in the FROM path of www.domain.com/product-name/xxx that nothing should because the second variable is no where in the domain.  I thought i would get a page not found since there is not existing 'xxx' file or directory.

Once again thanks for this help.

 

Coordinator
Jan 14, 2010 at 1:23 AM
Edited Jan 14, 2010 at 1:28 AM

> Am I correct to assume that when i place extra characters in the FROM path of www.domain.com/product-name/xxx that nothing should because the second variable is no where in the domain.  I thought i would get a page not found since there is not existing 'xxx' file or directory.

I'm not clear on what you are asking. 

Still you have some misunderstanding.  IIRF will map an externally-published URL to a URL space that is used internally.  If you are not fiddling around with host or domain names (most cases do not), then you don't need to worry or concern yourself with http://www.domain.com .  So we will speak only of the URL path, everything that falls AFTER http://www.domain.com . OK?

The URL paths you are rewriting are of the form /xxx .  You have a rule that rewrites them to /dynamicpage.cfm?url=xxx . That rule works successfully, I think.

Now you are asking about a URL of the form /xxx/yyy .  I don't know what you want to do with such URLs.  If you want to rewrite them, you have to know what you want to rewrite TO.  You haven't described that.

I don't understand the question.  I don't know what you mean by "the second variable is no where in the domain."  What is the second variable?  What domain?  I have no idea what you are talking about.

Rather than explaining the question though, maybe a better path to take is this:  Explain what mapping you want to perform, for URLs of the form /xxx/yyy .

You have said, "there is not existing 'xxx' file or directory."   I don't see how that is relevant.   xxx is not a file or directory.    In your example it is a segment in the URL path.  There is nothing that magically relates that URL path segment to a file or directory.

What your dynamicpage.cfm does with the xxx, is the concern of your application. IIRF attaches no meaning to the text in the URL path. That is up to your application. The only thing IIRF does is map between external URLs and internal URLs.

 

Jan 14, 2010 at 1:53 AM

Yes, i understand isapi rewrites as i was having issues with the rewrite of the path which you gave me the answer in your second response, thank you.  I was using the domain as part of the example to help reference, sorry if it was confusing.  I have been doing some searching to see any others that had any issue with the paths of the .dll and found a topic that related to some of the issues i was having.  My installation using the .msi failed and I had to manually install but I had an existing installation of IsapiRewrite4.dll.  My website within IIS had the Iirf.dll installed correctly and running but i had the IsapiRewrite4.dll in my extensions (even though i don't think that was an issue as I gave it rights on the domain).  Anyways, I deleted the old references as well as directories and moved the IIRF directory so I could manually attach again. I restarted services and now i can get the iirfstatus report (was wondering why i was never able to get the response, but now I have it).

The link that helped me was, http://iirf.codeplex.com/Thread/View.aspx?ThreadId=74153

 

The only problem that I had left was the reference to the application.root_path i have in my application.cfm (same function as web.config for .net).  Once I removed the old .dll, replaced with the new one and restarted services, that issue went away.  So in a nutshell it was never the iirf.dll that was causing the root_path issue, it was the duplicate of the IIRF.dll and IsapiRewrite4.dll and the missing rights of networkservice on the iirf.ini (even though it worked with the old .dll version).

In conclusion, based on how it is functioning now, if i want the option to rewrite the path, /product-name to dynamicpage.cfm?product=product-name and i want to rewrite /category-name/product-name to dynamicpage.cfm?Category=category-name&product=product-name do i need to have two rewrite rules in my .ini like below? (I am replacing URL as the reference i used above to help the conversation)

RewriteRule ^/([^/]+)         /dynamicpage.cfm?product=$1
RewriteRule ^/([^/]+)/([^/]+)$    /dynamicpage.cfm?Category=$1&Product=$2

 

Thanks again for your help.

 

Jan 14, 2010 at 3:31 PM
Cheeso wrote:

> Am I correct to assume that when i place extra characters in the FROM path of www.domain.com/product-name/xxx that nothing should because the second variable is no where in the domain.  I thought i would get a page not found since there is not existing 'xxx' file or directory.

I'm not clear on what you are asking. 

I do get the question.

What's happening, and why you're not getting a 404 page, is that effectively what you're asking the filter to do, using your RewriteCond statements, is to check and see if a file exists that isn't the specifed file types and if it *doesn't*, then to rewrite it to /dynamicpage.cfm etc.

You will never get a 404 error as /xxx will be rewritten to /dynamicpage.cfm?product=xxx

What I would suggest is that you check against the variable being picked up and if it doens't exist, use a custom error message.

Hope this helps.