简体   繁体   中英

Angular JS 1.x Deployment on IIS

I am newbie in Angular js, I just finished creating project on Angular js + material.

I ran command gulp build and moved all files from dist folder to IIS server directory; it is working fine for the instance but whenever I manually enter an address or refresh it or tries to go back it gives me a 404 error.

I ran through official documentation of Angular but it seems that it is not working at all because these are the errors from Angular 1.x and the official site shows the deployment of only Angular 2 and 4 deployment.

If the app in html5Mode and host in IIS as a Virtual Directory , it require URL Rewrite for refresh to work:

https://www.iis.net/downloads/microsoft/url-rewrite

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="AngularJS" stopProcessing="true">
                    <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="{0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM