Rewrite for specific folder/site

Aug 25, 2009 at 10:59 PM

I've got this installed, and it's in the ISAPI Modules on my IIS 7.0, but how do I add it on a per-folder basis?

I'm new to this, so any advice is appreciated... I'm better at mod_rewrite, but need to learn this so I can rewrite my IIS website URLs!

Coordinator
Aug 25, 2009 at 11:07 PM

Read the doc.  You need IIRF v2.0 - make sure you have that version. It's on the downloads tab.

There's a CHM file for IIRF.  It explains how to configure the filter. 

It does not work "per folder".  It works per "virtual directory" which is not the same thing, in IIS.

To configure per vdir, drop a file, IIRF.ini, in the toplevel directory of each vdir. 

This is all explained in the doc.

 

Aug 26, 2009 at 5:46 PM

I updated it to 2.0, however, with the IIRF.ini I can't rewrite a page name like this:

http://www.mycarsite.co.uk/thenews.asp to http://www.mycarsite.co.uk/thenews1.asp

(these are mapped via my HOSTS file and not real URLs!)

Do you know of a rewrite rule that can work for this site?

So far it's working well!

Coordinator
Aug 26, 2009 at 7:55 PM

it's working well but it's not rewriting?

what rules do you have now?  can you show me your ini file?

When you say "rewrite a page name like this:  A B" .....   Which of (A,B)  is the incoming URL, and which is the target of the rewrite? 

This rule:

  RewriteRule  ^/thenews\.asp$           /thenews1.asp  [L]

..will rewrite thenews.asp to thenews1.asp.

This rule:

  RewriteRule  ^/thenews1\.asp$           /thenews.asp  [L]

..will do the reverse.

 

Aug 26, 2009 at 8:08 PM

# Iirf.ini
#
# site or app-specific ini file
#

RewriteLog c:\temp\iirf.wwwroot
RewriteLogLevel 4
RewriteEngine On
StatusUrl /iirfStatus

MaxMatchCount 10

#poe is first param
RewriteLog c:\temp\iirfLog
RewriteLogLevel 0

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^thenews1.asp$ /thenews.asp [L]



That's my ini file for Iirf.ini, within my inetpub/wwwroot/mycarsite directory.

Coordinator
Aug 26, 2009 at 9:33 PM

why do you have those two RewriteCond directives?

Are you sure you need them?

 

Aug 26, 2009 at 10:17 PM
Edited Aug 26, 2009 at 10:18 PM
Cheeso wrote:

why do you have those two RewriteCond directives?

Are you sure you need them?

 

 I was testing those; removed them now.

I added that rewriterule; it didn't change; I got a 404 error on thenews1.asp

This is on a Vista machine with IIS 7.0 installed. Home edition of Vista for the record.

Coordinator
Aug 26, 2009 at 10:22 PM
Edited Aug 27, 2009 at 3:23 AM

I suggest that you set RewriteLogLevel to 3, and run another request through the filter.  Just one.  Then, look at the IIRF log file.    you may be able to see what is happening.  you can post it here if you need help.

Another idea - uninstall IIRF as a filter, and then do a GET on thenews1.asp.   Also do a get on thenews.asp.   What happens?

 

 

Aug 28, 2009 at 3:11 PM
Cheeso wrote:

I suggest that you set RewriteLogLevel to 3, and run another request through the filter.  Just one.  Then, look at the IIRF log file.    you may be able to see what is happening.  you can post it here if you need help.

Another idea - uninstall IIRF as a filter, and then do a GET on thenews1.asp.   Also do a get on thenews.asp.   What happens?

 How would I do that? How do I use the GET function?

Coordinator
Aug 28, 2009 at 6:24 PM
Edited Aug 28, 2009 at 6:25 PM
hawiell wrote:

 How would I do that? How do I use the GET function?

 Type the URL into the address bar in a web browser, and press ENTER.  The browser sends an HTTP GET to the server. 

Aug 31, 2009 at 11:57 AM
Cheeso wrote:
hawiell wrote:

 How would I do that? How do I use the GET function?

 Type the URL into the address bar in a web browser, and press ENTER.  The browser sends an HTTP GET to the server.

 GET function didn't work - the url remained the same!

Coordinator
Aug 31, 2009 at 10:17 PM

Hawiell, I think the goal is to investigate and get to a better understanding of what's going on.

You said "it didn't work."   Whn you're testing, all tests "work", it's just a matter of figuring out what the results mean, and what the next test ought to be.

I had earlier suggested several steps, several different ways to test.  I still think those are good things to try.  I don't think you tried them.   Configure the log, run a URL, then examine the log.  what does it tell you?  There's a line in the log for each incoming URL, and then a series of lines showing what the filter did with them.  Including, which rules fired, and which rules did not.  This is invaluable when diagnosing things you don't understand.  I also suggested you try two other URLs. 

You summed up your results of all my suggestions with  "didn't work - the URL remained the same!"  That's not enough. You're going to have to put a little more effort into this, if you want to solve it.  I spent more time and thought responding to this message, than you are willing to spend solving your problem.

I don't know what "the url remained the same" means.  Which URL remained the same?  both?  What did you get FOR EACH PAGE?  Did you get a 200 back?  a 404?  something else?   Was it what you expected?  And what about the logging?  

I actually don't want all these answers from you.  I am suggesting the questions YOU should investigate YOURSELF.  These are things you can try.   Then, think about what you are seeing.  Figure it out.  Only you clearly understand what you want. Only you can solve the problem.   I can only make suggestions.  

 

Sep 1, 2009 at 8:35 PM

OK this is my IIRF logfile:

Tue Sep 01 18:45:57 - 7876 - -------------------------------------------------------
Tue Sep 01 18:45:57 - 7876 - Ionic ISAPI Rewriting Filter (IIRF) v2.0k preview Time-stamp: <2009-August-22 13:56:00>
Tue Sep 01 18:45:57 - 7876 - IIRF was built on: Sat 08/22/2009 13:59:27.97
Tue Sep 01 18:45:57 - 7876 - Cached: DLL_PROCESS_ATTACH
Tue Sep 01 18:45:57 - 7876 - Cached: Process ID: 7792
Tue Sep 01 18:45:57 - 7876 - Cached: global ini file: 'C:\Windows\System32\inetsrv\iirf\IirfGlobal.ini'
Tue Sep 01 18:45:57 - 7876 - Cached: ReadServerConfig: Filter Priority is now: HIGH (0x80000)
Tue Sep 01 18:45:57 - 7876 - Cached: ReadServerConfig: NotifyLog setting is now: OFF
Tue Sep 01 18:45:57 - 7876 - Cached: Done with DLL_PROCESS_ATTACH
Tue Sep 01 18:45:57 - 7876 - Cached: GetFilterVersion
Tue Sep 01 18:45:57 - 7876 - GetLogFile: app:'/LM/W3SVC/2/ROOT' new log:'c:\temp\iirf.wwwroot.7792.log'
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: ini file: 'C:\inetpub\wwwroot\Iirf.ini'
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: ini file timestamp: 2008/06/14 01:17:52 GMT Daylight Time
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 7: LogLevel = 4
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: pass 1
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 9: MaxMatchCount 10
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 19: RewriteCond %{QUERY_STRING} VARCHAR
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 20: RewriteRule (rule 1) '.*' '/index.asp' [R]
Tue Sep 01 18:45:57 - 7876 - ParseRuleModifierFlags: '[R]'
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: ERROR: line 20: DO NOT USE [R] with RewriteRule - use RedirectRule instead!
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 24: RewriteCond %{QUERY_STRING} ^$
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 25: RewriteHeader (rule 1) 'Query-Is-Empty:' '.*' 'YaHuh' [L]
Tue Sep 01 18:45:57 - 7876 - ParseRuleModifierFlags: '[L]'
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 27: RewriteCond %{QUERY_STRING} ^.+$
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 28: RewriteHeader (rule 2) 'Query-Is-Not-Empty:' '^$' 'YaHuh' (null)
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: line 39: RewriteRule (rule 3) '^/(.*\?)poe=\w*&?(.*)$' '/$1$2' [R,L]
Tue Sep 01 18:45:57 - 7876 - ParseRuleModifierFlags: '[R,L]'
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: ERROR: line 39: DO NOT USE [R] with RewriteRule - use RedirectRule instead!
Tue Sep 01 18:45:57 - 7876 - ReadSiteConfig: Done reading, found 2 rules (2 errors, 0 warnings) on 46 lines
Tue Sep 01 18:45:57 - 7876 - GetSiteConfig: Obtain site '/LM/W3SVC/2/ROOT' (era=0) (rc=1) (Expired=0) (ptr=0x011230B0)...
Tue Sep 01 18:45:57 - 7876 - ReleaseOrExpireSiteConfig: site '/LM/W3SVC/2/ROOT' (era=0) (rc=0) (Expired=0) (ptr=0x011230B0)...
Tue Sep 01 18:45:57 - 7876 - IsIniFileUpdated: 'C:\inetpub\wwwroot\Iirf.ini'
Tue Sep 01 18:45:57 - 7876 - IsIniFileUpdated: NO
Tue Sep 01 18:45:57 - 7876 - GetSiteConfig: Obtain site '/LM/W3SVC/2/ROOT' (era=0) (rc=1) (Expired=0) (ptr=0x011230B0)...
Tue Sep 01 18:45:57 - 7876 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue Sep 01 18:45:57 - 7876 - HttpFilterProc: cfg= 0x011230B0

 

and the current IIRF file (but for a different site on same directory):



# Iirf.ini
#
# site or app-specific ini file
#

RewriteLog c:\temp\iirf.wwwroot
RewriteLogLevel 4
RewriteEngine On
StatusUrl /iirfStatus

MaxMatchCount 10

#poe is first param
RewriteLog c:\temp\iirfLog
RewriteLogLevel 0

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mypage000$ /mypage000.asp [L]


I think what I did removes the extension but am not quite sure!

Coordinator
Sep 2, 2009 at 5:06 AM

ok I hate to say this, but I forget the problem we're trying to solve.

Did you run a URL through the browser?  I see NO trace messages indicating that any URL was handled by the filter.  The only trace messages I see are those that indicate the ini file has been read.

I don't know what you mean by "here's the current IIRF file (but for a different site on same directory):" .   What does it mean "for a different site" ?   

You're showing me the config for a site that you're not using?  What is the point of that?

I'm haing a lot of trouble understanding what you are doing.  And when you gie me information, I don't even understand THAT.