0

My project using php and angular, it is hosted in IIS. I turn on html5Mode in angular, that mean I can use route like localhost/home instead of locahost/#/home.

My problem is when I copy & pass the url (ex: http://localhost/home) to another tab or browser, IIS return the error

Requested URL http://localhost/home/

Physical Path <physical link>\link\

I want using angular route (not ui-router) to handle all route in my application. How can I config the URL Rewrite to make it understand all routes just need point to the home?

My route of project is index.html. It's a normal html file.

In Asp.net MVC, I config that route like this:

routes.MapRoute( name: "Renewal SPA", url: "{*catchall}", defaults: new { controller = "Home", action = "Index" }); 

How to do the same with php?

1 Answer 1

1

You should config IIS rewrites in your config file (or in IIS) like this:

<system.webServer> <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="/" /> </rule> </rules> </rewrite> </system.webServer> 

Be sure that URL Rewrite installed on your IIS (download it from here).

See this article: Configure your server to work with html5Mode

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.