How to serve two folders (React build files) on one website on IIS?

冷暖自知 提交于 2021-01-29 14:40:25

问题


I have IIS web server, and I am using the IP address and :80 port to serve the website.

I have two applications. One of them should be served on '/' route, and another one should be accessible on '/admin' route.

I tried multiple advices about "how to serve two websites on one IP and Port", but they do not help me. I also created virtual directory with static files, but still cannot access the second app on '/admin' route

Can you please give me recommendations what do I need to add to "web.config" to make it work. I want the "app1" be on home route, that it, '/', and "app2" be on the "/admin" route, so

111.111.11.11/ - this is "app1"

111.111.11.11/about - this is still "app1"

111.111.11.11/admin - and when the use goes to admin, this is "app2"


回答1:


First, create child application or virtual directory under the mail application. give full access control isur and iis_iusrs.

Convert all absolute links to relative ones. Base tag works only for relative URLs. The bare minimum plain HTML example.

<img src="/assets/logo.svg"/> to <img src="./assets/logo.svg"/>

Add in your index.html. This tag should be placed in the ... before any other element that uses URLs. The best place to put it right above the ... in the index.html

    <head>
  ...
  <base href="%PUBLIC_URL%/">
  <title>React App</title>
</head>
<body>
  ...
</body>

Regards, Jalpa



来源:https://stackoverflow.com/questions/56007384/how-to-serve-two-folders-react-build-files-on-one-website-on-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!