I have an Angular 4 app in a IIS server, in the same server there is a .NET Web API. They are in diferents folders: angular app is in "/wwwroot/angular/" and web api in "/wwwroot/api/". When I do a request to web api, it works successfully, but when I try to navigate to an URL different to index.html using the Routing Module in angular app I get this message:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Also, I have two Web.Config files -one in each folder-.
My Angular Web. Config is:
<system.webServer>
<rewrite>
<rules>
<rule name="Angular 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="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
Web.config of WEB API
<configuration>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</configuration>
I researched in some questions like:
stackoverflow.com/questions/49833141/blank-page-when-publishing-angular-5-net-core-web-api
and
stackoverflow.com/questions/42865084/redirect-unknown-requests-to-index-html-in-springboot
But they doesn't work to me.
Anybody help me on this.
Thanks in advance.
The solution was move all the Angular files to root, at index.html I left <base href="/"> and make the web.config like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="^(.*)$" />
</rewriteMaps>
<rules>
<rule name="Angular Route" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="/api(.*)$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="?" />
</authorization>
</security>
</system.webServer>
</configuration>
In your web.config change <action type="Rewrite" url="/FIN360" /> and in your index.html from the <base href="/"> remove the / Try this else change <base href="./"> OR <base href="/FIN360">
Related
I'm facing this error (1) at this page https://anthonytd.com/171/2020-jan-products-roundup/
What I have tried
Enabled CORS in azure web app
Enabled Header configs in web.config
Resources
Azure Web app config
My web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
<add name="Access-Control-Allow-Credentials" value="true" />
</customHeaders>
</httpProtocol>
<rewrite>
<rules>
<rule name="WordPress: http://anthonytd.azurewebsites.net" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
<rule name="Redirect requests from default Azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^anthonytd\.azurewebsites\.net$" />
<add input="{HTTP_HOST}" pattern="^www\.anthonytd\.com$" />
</conditions>
<action type="Redirect" url="https://anthonytd.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Just found the problem and solution
Problem: Default embed (pasted for Product Hunt links) of Wordpress doesn't work with Product Hunt Embed
Solution: I have to add Custom HTML myself
I have put in this http redirectin the web config file but I keep getting a redirection loop. The website is a wordpress website and is being hosted on IIS7.5, it may also be worth metioning that I have a plug in called really simple ssl installed to handle the https redirects.
I will attach my web.config file below
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
<rewrite>
<rules><rule name="Main Rule" 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="index.php" /></rule>
<rule name="WordPress: http://www.google.com"
patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule></rules>
</rewrite>
<httpRedirect enabled="true" destination="http://www.google.com" httpResponseStatus="Permanent" />
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence="xmlrpc.php" />
</denyUrlSequences>
<requestLimits maxAllowedContentLength="50000000" />
</requestFiltering>
</security>
<handlers>
</handlers>
</system.webServer>
</configuration>
I have this web.config file and i want to add a code to it that will hide the .asp of a page in my website called "users.asp" . please how do i do it
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
Obviously you need the URL rewrite module installed, and you need IIS7 or above, this won't work on IIS6
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^users/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="users.asp" />
</rule>
</rules>
</rewrite>
Recommended reading:
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
I have a site that uses Worpress on part of it. I am having trouble with the index page.
With index.php the site loads the most recent posts, which is the desired action with the incorrect url. Without index.php, which is the desired url, the page loads the 404 template.
I have the site working locally correctly. The only thing I can think of, is the web.config is incorrectly routing this request. Since this is an area I don't deal well with, I was hoping to get some help to see if that was the issue.
Here is the web.config contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 2-1" stopProcessing="true">
<match url="." ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
It sounds like you don't have index.php in the list of Default Documents. Add index.php to the list as shown below. You can also do this through the IIS settings for Default Document.
<defaultDocument>
<files>
<clear />
<add value="index.php" />
<add value="index.asp" />
<add value="Default.asp" />
<add value="Default.htm" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
</files>
</defaultDocument>
I have finished an ASP.NET web site after making tests.
I am using UrlRewritingNet dll from http://www.urlrewriting.net/
Then I have published it in order to upload my server (Windows 7, IIS 7 installed). After typing my site's URL I get 404 - Not found error. This is because of missing or bad configuration on the server side. But I do not know what to do exactly.
Searched many times but could not find anything close to my problem.
For a last chance I am here. Can you help?
You can see my web.config content in the following:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="urlrewritingnet" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>
</configSections>
<system.web>
<httpModules>
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
</httpModules>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<handlers>
<remove name="PageHandlerFactory-ISAPI-4.0_32bit"/>
<add name="PageHandlerFactory-ISAPI-4.0_32bit" path="*.aspx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
<add name="reww" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
<add name="rewwibu" path="*.ibu" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
<urlrewritingnet configSource="ExternalRewrite.config"/>
</configuration>
This is my new Web.Config File:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<rewrite>
<rules>
<rule name="GoAnasayfa">
<match url="^([_0-9a-z-]+)/Anasayfa.ibu" ignoreCase="false" />
<action type="Rewrite" url="Default.aspx?lang={R:1}" appendQueryString="false" />
</rule>
<rule name="GoIletisim">
<match url="^([_0-9a-z-]+)/Iletisim.ibu" ignoreCase="false" />
<action type="Rewrite" url="Contact.aspx?lang={R:1}" />
</rule>
<rule name="GoDereceProgramlari">
<match url="^([_0-9a-z-]+)/DereceProgramlari/([_0-9a-z-]+).ibu" ignoreCase="false" />
<action type="Rewrite" url="DegreePrograms.aspx?lang={R:1}&derece={R:2}" />
</rule>
<rule name="GoOgrenci">
<match url="^([_0-9a-z-]+)/Ogrenci.ibu" ignoreCase="false" />
<action type="Rewrite" url="Ogrenci.aspx?lang={R:1}" />
</rule>
<rule name="GoKatalog">
<match url="^([_0-9a-z-]+)/([0-9]+)/([0-9]+)/([0-9])/Katalog.ibu" ignoreCase="false" />
<action type="Rewrite" url="Catalog.aspx?lang={R:1}&opID={R:2}&pmID={R:3}&oid={R:4}" />
</rule>
<rule name="GoDersDetay">
<match url="^([_0-9a-z-]+)/([0-9]+)/([0-9]+)/([0-9])/([0-9])/DersAyrintilari.ibu" ignoreCase="false" />
<action type="Rewrite" url="CourseDetail.aspx?lang={R:1}&opID={R:2}&pmID={R:3}&DersID={R:4}&dersKodu={R:5}" />
</rule>
<rule name="GoLLPKoordinatorleri">
<match url="^([_0-9a-z-]+)/LLPKoordinatorleri.ibu" ignoreCase="false" />
<action type="Rewrite" url="Coordinators.aspx?lang={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
When I type my web adress the address bar is filled with lang parameter like below:
http://somedomain.com/tr-TR/Anasayfa.ibu?lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr....
and then browser shows an error message:
Invalid Redirect URL
Try to add:
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
<remove name="Session"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
to your web.config under
<configuration>
...
<system.webServer>
...
<modules>
<!-- add here -->
</modules>
</system.webServer>
...
</configuration>
Why not use the URL rewrite module from Microsoft?
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
Be sure to install the correct version based on your system's setup. Then you can proceed with creating your rewrite rules as demonstrated here:
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module