Totally lost...REGEXP noob alert...HELP!!!!

Topics: Developer Forum, User Forum
Mar 4, 2010 at 5:04 PM

I am having a few issues...

 

Here's my setup so that my questions have some context:  I am using ColdFusion (version 6.1).  I created a dummy domain via my hosts file that points to (via IIS6) c:\inetpub\wwwroot\job_posts.  There is an IIRF.ini file in job_posts.  The dll is in c:\inetpub\rewrite\bin  the global ini file is also located in the bin folder. 

1.  My rewrite rule doesn't work at all...I just get a 404 when I try to use it.  When I do a status(http://localhost/job_posts/iirfstatus), it is looking for the iirf.ini file in wwwroot, not in job posts. Is there something I need to do so that it knows to look in the job_posts folder?

 

2. I will be the first to admit that I royally suck at regexp.  Am I doing this right?  Here is my rewrite rule: (again, the physical lovcation of this is in c:\inetpub\wwwroot\job_posts\ and the domain points to this directory (ie http://www.mydomain.com/ should call c:\inetpub\wwwroot\job_posts\index.cfm)


RewriteRule ^/job_posts/([^/]+)/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*.html)$ /job_posts/index.cfm?jobname=$1&company=$2&city=$4&state=$5&country=$6&client=$7[L,QSA]

so what this should do is take http://www.mydomain.com/cook/bk/troy/mi/us/bkco and rewrite it as http://www.mydomain/index.cfm?jobname=cook&company=bk&city=troy&state=mi&client=bkco (I tried this with the rule as above and without "/job_posts/")

the fact that this doesn't work may be a config issue or a regexp issue.  this doesn't work whether I have job_posts in the rule or not.  I also want to get this to use dashes instead of forward slashes...am I replace the forward slash next to the question mark or the one in the parens?    I get easily confused with regexp, so please excuse the stupid noob question.  Sometimes I may as well be looking at hieroglyphs (which someones make more sense than regexp hehehe)

 

I really need to get this done asap, so any help on this will be very much appreciated.

 

Thanks!

Eric

Coordinator
Mar 4, 2010 at 5:24 PM
Edited Mar 4, 2010 at 5:25 PM

Eric,

#1, yes - you need to make the job_posts vdir into an IIS Application. This is done in IIS Manager. 

 #2.  You want to take http://www.mydomain.com/cook-bk-troy-mi-us-bkco and rewrite it as /index.cfm?jobname=cook&company=bk&city=troy&state=mi&client=bkco. By my count, there are 6 segments, separated by dashes. Each segment maps to a query string param. I'll assume that you require that each segment must be present, in other words each one must have one character at least. In that case I will use the + quantifier ("one or more") instead of the * quantifier (zero or more). I'll also assume there's nothing that follows the six segments. How about this:

RewriteRule  ^/([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)$ 
             /index.cfm?jobname=$1&company=$2&city=$3&state=$4&country=$5&client=$6  [L]

(the above rule should be all-on-one-line in your ini file.)

Your rule was not correct, but it wouldn't have done anything anyway, because you didn't have the IIRF.ini file being read.

 

Good luck!

 

Mar 4, 2010 at 5:55 PM

it is a virtual host...to use the apache term.  In your example...job_posts would be what bellvue is in your example (and I think it is going to drive me to bellvue LOL).  It came up as "default application", does it need to be named?  If so, does it get named the name of the directory or the domain that points to it?

 

also...new instructions from the powers that be...the last var will come up in the SEO friendly url as client+name.html (ie http://www.mydomain.com/cook-bk-troy-mi-us-bkco.html).  Do I have to add anything to the rule to accommodate this?

 

Thanks...you have been most helpful!

 Eric

 

Mar 4, 2010 at 6:08 PM

status info...

<!-- p,tr,td,body,a { font-family: Verdana, Arial, Helvetica; font-size: 9pt } h1 { color: #4169E1;} h2 { color: #1E90FF;} table { border: 1 gray; padding: 0 0 0 0;} tr td { color: Navy; } tr th { color: #00008B; background: #E6E6FA; } td {padding: 0em 1em 0em 1em; } -->

IIRF Global Status

IIRF Version Ionic ISAPI Rewriting Filter (IIRF) 2.0.1.15 RELEASE
Built on Dec 3 2009 11:49:15
Filter DLL C:\Inetpub\rewrite\bin\IIRF.dll 
Started 2010/03/04 14:06:09 Eastern Standard Time
Current time 2010/03/04 14:07:08 Eastern Standard Time
Server Ini file C:\Inetpub\rewrite\bin\IirfGlobal.ini 
Last Update of Ini -- the ini file could not be opened (error=2) -- 
  #Lines 0
  #Warnings 0
Rewrite Engine (all sites) ON

IIRF Site Status

APPL_MD_PATH /LM/W3SVC/1/ROOT
Ini file c:\inetpub\wwwroot\Iirf.ini
Ini file timestamp (file not found)
  Last read 2010/03/04 14:07:08 Eastern Standard Time
  #Ini Modules 0
  #Lines 0
  #Rules 0
  #Warnings 0
  #Errors 0
Log file (none)
Log level 1
Rewrite Engine ON
Remote Status Inquiry disabled
URL Decoding ON
#Requests Processed 1
Mar 4, 2010 at 6:22 PM

OK...I changed something and it worked :-D  Thanks a bunch for your help!!!!

 

Eric

 

Coordinator
Mar 4, 2010 at 6:49 PM
ThreeRavens wrote:

it is a virtual host...to use the apache term.  ... It came up as "default application", does it need to be named?  If so, does it get named the name of the directory or the domain that points to it?

 

Yes, it needs to be named, if you want the IIRF.ini to apply only to that. the IIS Application is the unit of management or administration that IIRF taps into for configuration files. If you need only one IIRF.ini file, then you can just use a single (default) IIS application. If you'd like different IIRF configuration for different vdirs, then you need to create distinct IIS applications for each such vdir, by clicking the button as I showed in the graphic. The name doesn't matter. The existence of an application is what's important.

also...new instructions from the powers that be...the last var will come up in the SEO friendly url as client+name.html (ie http://www.mydomain.com/cook-bk-troy-mi-us-bkco.html).  Do I have to add anything to the rule to accommodate this?

Yes.  Append \.html before the $ in the test pattern.  Eg: 

RewriteRule  ^/([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)\.html$ 
             /index.cfm?jobname=$1&company=$2&city=$3&state=$4&country=$5&client=$6  [L]

 

Mar 18, 2010 at 3:41 PM
Edited Mar 18, 2010 at 4:47 PM

One last question...I hope ;-)  I am adding a second rewrite rule to the ini file:

 

rewriteRule  ^/([A-Za-z][A-Za-z][A-Za-z])\.htm$ /job_list.cfm?client_code=$1

 

this will be taking the following url:  http://www.mydomain.com/chc

 

According to The Regex Coach, the regex is good.  All of the codes passed will contain 3 letters only (any way to make it more dynamic so if in the future they start using 4 character codes, it will just take it?) , but when I put the rewrite rule in, it doesn't work

 

Here are contents of the ini file.  Am I missing a directive or anything like that.  Thanks again...you have been most helpful and I have to say that this is the best product I have run across...better than the paid ones I researched.  Thanks for your work!

 

RewriteLog c:\logs\iirf
RewriteRule  ^/([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)\.htm$ /index.cfm?jobname=$1&company=$2&city=$3&state=$4&country=$5&postal_code=$6&job_id=$7&client=$8  [L]
rewriteRule  ^/([A-Za-z][A-Za-z][A-Za-z])\.htm$ /job_list.cfm?client_code=$1 [L]

 

Eric