隐藏

VUE 项目单独部署在IIS的时候WebConfig配置方法

发布:2022/9/28 16:59:38作者:管理员 来源:本站 浏览次数:817

当VUE项目以二级目录的形式部署正在IIS的时候,直接上代码(web.config):


<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="Handle History Mode and custom 404/500" stopProcessing="false">

<match url="(.*)" />

<conditions logicalGrouping="MatchAll">

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

</conditions>

<action type="Rewrite" url="/二级目录的名称/" />

</rule>

</rules>

</rewrite>

       <staticContent>

           <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />

       </staticContent>

</system.webServer>

</configuration>


再来一个多个反向代理时候的WebConfig配置信息


<?xml version="1.0" encoding="UTF-8"?>

<configuration>

 <system.webServer>

   <rewrite>

     <rules>

               <clear />

               <rule name="upload" enabled="true" patternSyntax="Wildcard" stopProcessing="true">

                   <match url="*Upload/*" />

                   <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />

                   <action type="Rewrite" url="http://localhost:5010/Upload/{R:2}" />

               </rule>

               <rule name="api" enabled="true" patternSyntax="Wildcard" stopProcessing="true">

                   <match url="*api/*" />

                   <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />

                   <action type="Rewrite" url="http://localhost:5010/api/{R:2}" />

               </rule>

               <rule name="hubs" enabled="true" patternSyntax="Wildcard" stopProcessing="true">

                   <match url="*hubs/*" />

                   <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />

                   <action type="Rewrite" url="http://localhost:5010/hubs/{R:2}" />

               </rule>

               <rule name="index" stopProcessing="true">

                   <match url="^((?!(api)).)*$" />

                   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">

                       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

                       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

                   </conditions>

                   <action type="Rewrite" url="/" />

               </rule>

     </rules>

   </rewrite>

 </system.webServer>

</configuration>