ionics - beginners problem

Topics: User Forum
Oct 29, 2007 at 3:58 PM
Edited Oct 29, 2007 at 4:01 PM
Hi,
I'm using ionics isapi rewrite filter with IIS 6.0.
I want to set a rule that rewrites whatever.mydomain.org to mydomain.org/whatever,
where 'whatever' represents an arbitrary string not containing a dot.
My config file looks like this:
RewriteCond %{HTTP_HOST} [^.]+.mydomain.org
RewriteRule ^/$ mydomain.org/%1


This does not work. In the log file there's a message that %1 does not exist, the value is defaulted to an empty string.
Any help would be deeply appreciated.
Thanks in advance
Nov 2, 2007 at 3:39 PM
RewriteRule ^/(.*)$ mydomain.org/%1

%1 matches up with the first set of () %2 with the second and so on....
Nov 2, 2007 at 3:44 PM
Edited Nov 2, 2007 at 3:46 PM
that won't actually fix your problem though.

more like this, but i'm not positive on the syntax.

RewriteRule ^(.*)\.mydomain\.org(.*)$ mydomain.org/%1/%2
Nov 6, 2007 at 12:03 PM


RewriteRule ^(.*)\.mydomain\.org(.*)$ mydomain.org/%1/%2

This will not work, as a RewriteRule does not receive the host directly. That means, that if I enter an URL like: whatever.mydomain.org/someparametr, the RewriteRule will only receive '/someparameter' and the host name is stored in a variable HTTP_HOST.
The ionic manual states, that I can use RewriteCond to check if a variable value matches a regex, and than use the %n syntax to retrieve matched text (in this case the http host), but I can't get it to work.
Regards
Nov 21, 2007 at 9:34 AM
I need the solution to this problem kinda desperately, thought I would send an e-mail or a private message to the creator of the Ionics Filter. Anybody knows who that is?
Thanks in advance.
Coordinator
Nov 21, 2007 at 9:52 AM
What's the message you see in the logfile ?
can you post that? (try double curly braces to avoid formatting)
Nov 21, 2007 at 10:15 AM
Hello,
this is what loading of the ini file looks like:

Read .ini file: new log file name: c:\temp\iirfLog.out.3536.log
Mon Oct 29 16:36:29 2007 - Read .ini file: setting LogLevel to 5
Mon Oct 29 16:36:29 2007 - ini line  43: RewriteCond %{HTTP_HOST}          [^.]+.mydomain.pl                          
Mon Oct 29 16:36:29 2007 - ini line  44: RewriteRule   1 ^/$                   mydomain.pl/%1/Default.aspx                  (null)
Mon Oct 29 16:36:29 2007 - not a duplicate rule...
Mon Oct 29 16:36:29 2007 - Done reading .ini file: Found 1 rules (0 failed) on 48 lines

then, the url rewrite looks like:

New Url: '/'
Mon Oct 29 16:40:28 2007 - ApplyRules (depth=0)
Mon Oct 29 16:40:28 2007 - Rule 1 : 1 matches
Mon Oct 29 16:40:28 2007 - GetServerVariable: getting 'HTTP_HOST'
Mon Oct 29 16:40:28 2007 - GetServerVariable: xferred 23 bytes
Mon Oct 29 16:40:28 2007 - GetServerVariable: result 'somename.mydomain.pl'
Mon Oct 29 16:40:28 2007 - ReplaceServerVariables: VariableName='HTTP_HOST' Value='somename.mydomain.pl'
Mon Oct 29 16:40:28 2007 - ReplaceServerVariables: InputString='%{HTTP_HOST}'out='somename.mydomain.pl'
 
Mon Oct 29 16:40:28 2007 - GenerateReplacementString: src='/','(null)' ReplacePattern='somename.mydomain.pl'
vec=[[  [  0, 1] [] ] counts=1,0
Mon Oct 29 16:40:28 2007 - EvaluateCondition: checking 'somename.mydomain.pl' against pattern '[^.]+.mydomain.pl'
Mon Oct 29 16:40:28 2007 - Cond : 1 (match)
Mon Oct 29 16:40:28 2007 - Cond : Child is NULL
Mon Oct 29 16:40:28 2007 - EvaluateConditionList: TRUE, Rule will apply
Mon Oct 29 16:40:28 2007 - ReplaceServerVariables: InputString='mydomain.pl/%1/Default.aspx' out='mydomain.pl/%1/Default.aspx'
Mon Oct 29 16:40:28 2007 - GenerateReplacementString: src='/','somename.'mydomain.pl' ReplacePattern='mydomain.pl/%1/Default.aspx' vec=[[  [  0, 1] [  0, 22] ] counts=1,1
Mon Oct 29 16:40:28 2007 - GenerateReplacementString: Substring index out of range (%1)
Mon Oct 29 16:40:28 2007 - Result (length 25): mydomain.pl//Default.aspx
Mon Oct 29 16:40:28 2007 - ApplyRules (depth=1)
Mon Oct 29 16:40:28 2007 - Rule 1 : -1 (No match)
Mon Oct 29 16:40:28 2007 - ApplyRules: returning 0
Mon Oct 29 16:40:28 2007 - ApplyRules: returning 1
Mon Oct 29 16:40:28 2007 - Rewrite Url to: 'mydomain.pl//Default.aspx'

Of course I was expecting 'mydomain.pl/somename/Default.aspx'
Looking forward to hearing from You,
thanks for all your help
Regards
Jan 21, 2008 at 4:22 AM
Has a solution to this problem been found?

I am also trying to achieve -

xyz.domain.com = www.domain.com/xyz/

I found a write u p on ISAPI_Reqrite here - http://www.seoconsultants.com/windows/isapi/subdomains/ and this one helped out a lot on other parts of the config like DNS, IIS etc but the rewriterule doesn't work as explained -

  1. If the web site starts with www then point the file to the root folder
  2. If you specifically created a folder /www/ then you can comment out this section.
RewriteCond Host: (?:www\.)example.com
RewriteRule (.*) $1 I,O,L

  1. Any web site starts other than www will be re-mapped to /<subdomain>/
  2. Example: http://sub1.example.com/default.asp -> /sub1/default.asp
  3. Note: if the folder does not exists, then the user will get a 404 error automatically.
RewriteCond Host: (.*)\.example.com
RewriteRule (.*) /$1$2 I,O,L
Coordinator
Jan 30, 2008 at 5:05 PM
Jethro, etc:
you have in your config
RewriteCond %{HTTP_HOST} [^.]+.mydomain.org
RewriteRule ^/$ mydomain.org/%1

I think you want
RewriteCond %{HTTP_HOST} ([^.]+).mydomain.org
RewriteRule ^/$ mydomain.org/%1

The key change - you need the ( ) parenthesis in order to capture the subdomain in the RewriteCond.