iT邦幫忙

0

IIS URL Rewrite 怎麼設定?

我的網站需要呼叫不同的API,所以我在 proxy.config.json 這樣設定

{
"/api/": {
"target": "https://localhost:5001",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
},
"/wapi/": {
"target": "https://localhost:8009",
"secure": false,
"logLevel": "debug",
"changeOrigin": true,
"pathRewrite": {
"^/wapi/": "/api/"
}
}
}

開發環境都沒問題。但是,要deploy到 IIS要怎麼做? 用 URL Rewite 嗎?

我自已試了2天,但都試不成功。
貼上我的 web.config 部份內容,請大家指教

<rewrite>
<rules>
<rule name="Redirect to port 8009" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{URL}" pattern="(.*)(:\d{2,4})\/(wapi)(.*)" />
</conditions>
<action type="Rewrite" url="{C:1}:8009/api:{C4}" appendQueryString="true" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
froce iT邦大師 1 級 ‧ 2020-06-11 14:06:27 檢舉
https://ithelp.ithome.com.tw/questions/10195717
之前寫的範例
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答