Lali
Lali

Reputation: 2866

How to host AngularJs application over IIS

I am new to AngularJs application and using Gulp to compile application. When I compile my application, it creates a directory with name app in my solution. I have the following folders in app.

enter image description here

This is deployable code and I want to deploy it on local IIS. What is needed to tell IIS to start from or is configuration file needed there.

I set application pool like this

enter image description here

Any help please despite this awkward illustration.

Upvotes: 2

Views: 8345

Answers (1)

CozyAzure
CozyAzure

Reputation: 8478

This is not hard, as long as you are in control of your web.config. Basically what you need to do is a 301 Permanent Redirect.

This is how to do a mod_rewrite in IIS, under your web.config:

<system.webServer>
 <rewrite>
  <rules>
    <rule name="directToSubFolder" stopProcessing="true">
      <match url="^$" />
      <action type="Rewrite" url="/app/index.html" />
    </rule>
  </rules>
 </rewrite>
</system.webServer>

Note that the url in the action tag value should be whatever that suits your needs. I am assuming your default landing is an index.html

So with this, you can do your development as usual, once you want to deploy, you can run Gulp to build everything into app folder, and voila, you are done!

Upvotes: 1

Related Questions