Proper method to remove www from address using IIS URL Rewrite

If you want it to work with any hostname (not hardcoding it into the rule), you’d want to do something like this: <rule name=”Remove www” stopProcessing=”true”> <match url=”(.*)” ignoreCase=”true” /> <conditions logicalGrouping=”MatchAll”> <add input=”{HTTP_HOST}” pattern=”^www\.(.+)$” /> </conditions> <action type=”Redirect” url=”http://{C:1}/{R:0}” appendQueryString=”true” redirectType=”Permanent” /> </rule> in the redirect action, the {C:1} contains the second capturing group … Read more

IIS AAR – URL Rewrite for reverse proxy – how to send HTTP_HOST

This post has the answer – Modifying headers with IIS7 Application Request Routing Need to enable preserveHostHeader – can’t see how you do that in the UI but this works Run this from command line to update Machine/webroot/apphost config %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost

URL Rewrite keeps original host Location when reverse proxy 301 redirects

Could Application Request Routing be involved? Look at IIS -> Machine or Site -> Application Request Routing Cache -> Server Proxy Settings and uncheck the “Reverse rewrite host in response headers” checkbox. If you do this at the machine level, it’ll take effect for all sites. If you do it on a particular site, it’ll … Read more

Prevent IIS from serving static files through ASP.NET pipeline

I’m taking a guess here and suspect that you have the following setting configured in your web.config file: <modules runAllManagedModulesForAllRequests=”true”> This means that every request, including those for static content is hitting the pipeline. Change this setting to: <modules runAllManagedModulesForAllRequests=”false”> This is assuming your application is running under ASP.NET 4.0 and MVC3. For this to … Read more

Get Angular2 routing working on IIS 7.5

(For angular 2, angular 4) Create a web.config file as in mentioned article. <configuration> <system.webServer> <rewrite> <rules> <rule name=”AngularJS Routes” 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=”https://stackoverflow.com/” /> </rule> </rules> </rewrite> </system.webServer> </configuration> Place it in the root directory (same as index.html) … Read more

IIS 7.5 Fixing An attempt was made to load a program with an incorrect format problem?

Found the problem – The solution is in the way that the two AppPools are configured: Default Website/my_app is using DefaultAppPool where Enable 32-Bit applications is TRUE Beta/my_app -> BetaAppPool is using Enable 32-Bit applications is FALSE Changing BetaAppPool to set Enable 32-Bit applications to TRUE has fixed this problem. Solution was found by @Rick … Read more