First, I had this issue, link, and after some reading and some tests I noticed a problem with the url while refreshing the page using ui-router
with html5
mode enabled.
Problem
The problem occurs when I used an extend url, for example /app/Welcome
. At first, I tought it was because of the nested state, since I was only using this type of url when I had a child state. But the problem also happened when I tried to access an url with parameters. These are the url I've tested so far:
url: 'Service/Tools' url: '/Service/Tools' url: '/Service/:myParam' url: '/Service/Tools/:myParam'
For all of these url, when I refresh the page there is this error:
Uncaught SyntaxError: Unexpected token <
Uncaught ReferenceError: angular is not defined
Resource interpreted as Stylesheet but transferred with MIME type text/html:
The only way I was able to refresh the page using html5mode
enabled, was using a url like this: url:'/Service'
.
It doesn't matter if it's a single state, nested state, abstract, etc.. If the url has more than 1 /
, the error apear.
Server
I'm running this on an apache server with this rewrite rule:
<IfModule mod_rewrite.c>
RewriteEngine On RewriteBase /
Options FollowSymLinks
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
Does anyone have any idea on how to solve this?