1

有人可以帮我将以下伪代码翻译成Helicon Tech 的 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
}

文档让我很困惑。

非常感谢任何和所有帮助。

4

4 回答 4

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 您必须替换%{HTTP_HOST}byHost:才能获取当前主机。

于 2009-01-21T13:10:00.537 回答
2

这是版本 3 之前使用的“旧”语法:

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

正则表达式本身在两个版本中都是相同的。

于 2009-01-21T13:23:31.290 回答
1

请注意,ISAPI 3 轻量版不支持上述每个目录的 httpd.ini 方法:http ://www.helicontech.com/isapi_rewrite/doc/litever.htm

于 2010-08-12T07:05:56.150 回答
0

感谢 Gumbo 和 Tomalak 的努力。真的很感激。

不过,我想出了另一种方法:您将一个包含特定重写的文件(httpd.ini)放在该虚拟目录/域的根文件夹中的特定虚拟目录/域中。

这也消除了对全局配置文件的污染。

于 2009-01-21T13:54:17.780 回答