How to get the rules to rewrite according to the db records?

Oct 30, 2008 at 5:09 AM
Edited Oct 31, 2008 at 1:19 PM
How to rewrite with records of the database to achieve the domain of the directory and binding
IIRF support through access with the MSSQL get rewrite rules?

For example:

Database Records

HTTP_HOST                           directory     -->       /codeplex/index.html           -->       /codeplex/index.html         -->       /google/index.html            -->       /google/index.html           -->       /google/index.html     -->       /msdn/index.html              -->      /enbbc/index.html
Oct 30, 2008 at 10:20 PM
I am able to read the words you have written, but I am not able to make sense of them.
As a result, I have no idea what you want.
Can you please elaborate or ask your question a different way? 
Oct 31, 2008 at 12:36 PM
Edited Oct 31, 2008 at 1:53 PM
Whether the IIRF can  support to read the rewriting rules from the database,and how? For example, I have a set of records, which have the field of "domain" and "folder". "" and "/ codeplex" are respectively the strings of the two fields.
When the server receives the HTTP head of ""
(For example: select folder from tablestring where domain=''),
 it will rewrite the URL to the default document under the"/codeplex/index.html". 

Code way:
RewriteLog c:\iirfLog.out
RewriteLogLevel 0

#Database is MSSQL


RewriteCond %{HTTP_HOST} ^.*\.[^google]\.[^cn]$ [I]
SQLExecute(select dir,folder from Url_Rules where domain = '%1')
RewriteRule  ^(.*)$  /$1/$2/$3 [L]
$1 = Rs("dir")
$2 = Rs("folder")
$3 = (.*)

Oct 31, 2008 at 6:19 PM
Edited Nov 2, 2008 at 6:02 AM
Ok, thank you for the clarification.
No, IIRF gets the rules and configuration from the ini file.
If you have rules in a database, I could imagine producing a trigger that executes when the rules table is updated. The trigger would then write out a fresh ini file, which would then be read by IIRF.
You would have to write the trigger.
If you do not expect the rules to change very often, then the logic to generate the ini file need not be a trigger. It could just be a Stored Procedure, or a script, that you run periodically from the Windows Task Scheduler.
Oct 31, 2008 at 6:40 PM
Edited Nov 2, 2008 at 6:01 AM
or just run the script manually, whenever necessary.
Oct 31, 2008 at 7:20 PM
Edited Oct 31, 2008 at 7:32 PM
OK,Thank you!
But the rules to change very often.
Can you add regular expressions to the script of support?
I think that the rules will be very flexible.
For example: 
ini file

RewriteCond %{HTTP_HOST} ^.*\.[^codeplex]\.[^com]$ [I]
SQLExecute(select dir,folder from Url_Rules where domain = '%1')
RewriteRule  ^(.*)$  /$1/$2/$3 [L]

MS-SQL records
domain dir folder a google a google a google a google a google

Results:  -->  /a/google/index.htm  -->  /a/google/index.htm  -->  /a/google/index.htm  -->  /a/google/index.htm  -->  /a/google/index.htm  -->  /a/google/index.php

I hope you can help me, thanks very much!
Oct 31, 2008 at 7:50 PM
Edited Nov 2, 2008 at 6:00 AM
You asked:
You can add regular expressions to the script of support?
I'm sorry. Once again, I don't understand what you are asking. IIRF already supports regular expressions.
Maybe you have not understood what I wrote?
I am suggesting that YOU can write a script to generate the ini file from the database contents.
If you are asking if I can enhance IIRF to read rules from the database - no, I cannot do that.
That would be a major undertaking, a significant design effort, and would require lots of testing required to make it work.
It would significantly expand the footprint of IIRF and would introduce reliability risks. This is beyond the scope of something I could do.
Writing a script to retrieve information from a database and then emit an ini file - that seems much simpler and easier.
Why don't you try that?
Nov 1, 2008 at 6:41 AM
I'm sorry Cheeso,my English is too bad!
but thank you to your help.
I think so,Writing a script to retrieve information from a database,It is not be able to meet.
Because the ini file,it is will be very very long, and logic will be Complex.
IIRF is a great project!
Nov 4, 2008 at 6:37 PM
Thanks for the comment, sorry I couldn't be of more help. Good luck!
Aug 28, 2009 at 1:16 AM

i've gone down the path of dynamically writing the .ini file whenever changes occur- within our CMS- and have found it to work very well.

simple database query to get list of pages, run through pages and apply rule to each, then save the ini file.

doesnt even need a site restart.

great little app btw cheeso