将IIS重写规则转换为Apache

时间:2015-10-05 21:21:20

标签: apache mod-rewrite iis url-rewriting proxy

因此我无法将IIS中的重写规则转换为Apache。在IIS中运行良好,但在apache中完全没有。

原始IIS重写规则:

RewriteEngine on
RewriteRule ^api/(.*)$ http://api.testdomain.com/$1 [P]

我尝试的Apache规则:

 CREATE PROCEDURE getNextID (
    @NextNumber int OUTPUT
    ,@id_type VARCHAR(20)
    )
AS
BEGIN

    SELECT @NextNumber = (last_used_number + 1)
    FROM its_id_sequence WITH (UPDLOCK)
    WHERE id_type = @id_type

    UPDATE its_id_sequence
    SET last_used_number = @NextNumber
    WHERE id_type = @id_type
END

1 个答案:

答案 0 :(得分:0)

所以看起来我并没有尊重原始规则中的原始pod,其中包含' / api'随着请求。下面修改后的规则现在就像一个魅力(尽管我已经硬编码了路径的' / api'部分,但结果相同)。

原始IIS重写规则:

    <rule
    enabled="true"
    stopProcessing="true"
    name="Route API calls to test server”>
    <match url="(api/.*)" />
    <action type="Rewrite" url="http://api.testdomain.com/{R:1}" />
    </rule>

Apache规则

    RewriteEngine on
    RewriteRule ^/api/(.*)$ http://api.testdomain.com/api/$1 [P]