首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Helicon Tech - ISAPI_Rewrite:针对特定领域的重写规则

问Helicon Tech - ISAPI_Rewrite:针对特定领域的重写规则
EN

Stack Overflow用户
提问于 2009-01-21 13:04:40
回答 4查看 3.4K关注 0票数 1

有人能帮我把下面的伪代码翻译成Helicon Tech's ISAPI_Rewrite module能理解的代码吗?

代码语言:javascript
复制
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对我来说非常困惑。

任何帮助都是非常感谢的。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2009-01-21 13:54:18

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

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

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

票数 0
EN

Stack Overflow用户

发布于 2009-01-21 13:10:01

如果ISAPI_Rewrite的工作方式与Apache的mod_rewrite相同,那么可以尝试这样做:

代码语言:javascript
复制
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:才能获得当前主机。

票数 3
EN

Stack Overflow用户

发布于 2009-01-21 13:23:31

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

代码语言:javascript
复制
RewriteCond Host: ^(www\.)?something\.com$
RewriteRule ^/something$ /something/something.aspx

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

这将是版本3和更高版本的新语法。这更接近于mod_rewrite:

代码语言:javascript
复制
RewriteCond %{HTTP:Host} ^(www\.)?something\.com$
RewriteRule ^/something$ /something/something.aspx

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

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/465216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档