1

誰かが次の擬似コードをHeliconTechの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

注: RFC2606に従って他のドメイン名を使用しました。


編集: ISAPI_Rewriteの場合、現在のホストを取得するには%{HTTP_HOST}、をに置き換える必要があるようです。Host:

于 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

上記のディレクトリごとの httpd.ini メソッドは、ISAPI 3 ライト バージョンではサポートされていないことに注意してください: http://www.helicontech.com/isapi_rewrite/doc/litever.htm

于 2010-08-12T07:05:56.150 に答える
0

ガンボとトマラクの努力に感謝します。心から感謝する。

ただし、別のアプローチを考え出しました。特定の仮想ディレクトリ/ドメインへの特定の書き換えを保持するファイル (httpd.ini) を、その仮想ディレクトリ/ドメインのルート フォルダーに配置します。

これにより、グローバル構成ファイルも汚染されなくなります。

于 2009-01-21T13:54:17.780 に答える