2009-01-21 112 views
1

有人能幫助我下面的僞代碼轉換成由Helicon Tech's ISAPI_Rewrite module理解代碼:Helicon的技術 - 的ISAPI_Rewrite:重寫規則對特定領域

if (domain == something.com OR domain == www.something.com) 
{ 
    // The rules inside this scope will only apply to the domain: 
    // something.com/www.something.com 

    // This should match "something.com/test" and/or "www.something.com/test" 
    RewriteRule /something /something/something.aspx 
} 


if (domain == test.com OR domain == www.test.com) 
{ 
    // The rules inside this scope will only apply to the domain: 
    // test.com/www.test.com 

    // This should match "test.com/test" and/or "www.test.com/test" 
    RewriteRule /test /test/test.aspx 
} 

documentation非常混亂給我。

任何和所有的幫助,非常感謝。

回答

0

感謝Gumbo和Tomalak的努力。真的很感激它。

我已經想出了另一種方法,但是:您將一個文件(httpd.ini)保存到特定虛擬目錄/域的特定虛擬目錄/域中。

這也消除了污染全局配置文件。

3

如果下ISAPI_Rewrite的工作方式相同Apache的mod_rewrite,試試這個:

RewriteCond %{HTTP_HOST} ^(www\.)?something\.example$ 
RewriteRule ^/something$ /something/something.aspx 

RewriteCond %{HTTP_HOST} ^(www\.)?test\.example$ 
RewriteRule ^/test$ /test/test.aspx 

注:我根據RFC 2606使用其他域名。


編輯:似乎爲下ISAPI_Rewrite你必須Host:更換%{HTTP_HOST}來獲得當前的主機。

2

這是「老」的語法,3.0版本之前使用:

RewriteCond Host: ^(www\.)?something\.com$ 
RewriteRule ^/something$ /something/something.aspx 

RewriteCond Host: ^(www\.)?something\.com$ 
RewriteRule ^/test$ /test/test.aspx 

這將是新的語法,3及以上版本。這更接近mod_rewrite:

RewriteCond %{HTTP:Host} ^(www\.)?something\.com$ 
RewriteRule ^/something$ /something/something.aspx 

RewriteCond %{HTTP:Host} ^(www\.)?something\.com$ 
RewriteRule ^/test$ /test/test.aspx 

正則表達式本身在兩個版本中都是相同的。

+0

我認爲新的語法應該是%{HTTP_HOST}(下劃線的,而不是結腸)。 – 2009-01-21 13:28:55

+0

這是他們自己的語法轉換工具給我的。 – Tomalak 2009-01-21 13:29:50