将IIS重写规则转换为Apache
问题描述:
因此,我无法将IIS中的此重写规则转换为Apache。在IIS中工作良好,但在Apache中完全没有。将IIS重写规则转换为Apache
原始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>
我正在尝试
阿帕奇规则:
RewriteEngine on
RewriteRule ^api/(.*)$ http://api.testdomain.com/$1 [P]
答
所以看起来我并没有履行在携带原有规则的原始荚'/ 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>
阿帕奇规则
RewriteEngine on
RewriteRule ^/api/(.*)$ http://api.testdomain.com/api/$1 [P]
你想代理这个请求,或者只是重定向/重写到新的网址是什么? –
代理。想想我已经想通了。在下面回答。 –