有人能帮我把下面的伪代码翻译成Helicon Tech's ISAPI_Rewrite module能理解的代码吗?
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对我来说非常困惑。
任何帮助都是非常感谢的。
发布于 2009-01-21 13:54:18
感谢Gumbo和Tomalak的努力。真的很感谢。
不过,我已经想出了另一种方法:将一个包含特定重写的文件(httpd.ini)放在该虚拟目录/域的根文件夹中。
这也消除了对全局配置文件的污染。
发布于 2009-01-21 13:10:01
如果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}替换为Host:才能获得当前主机。
发布于 2009-01-21 13:23:31
这是在版本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正则表达式本身在两个版本中都是相同的。
https://stackoverflow.com/questions/465216
复制相似问题