I have been looking around for a while but even after all the stackoverflow and other content I haven't got this to work.
I can turn AngularJS 1.x urls into pretty urls (so removing the fragment by replacing # by /) just fine when starting from the homepage. But on any other page, the javascript, css and other files can't load because the url to them is wrong. For example:
Correct url: localhost/css/app.css
Wrong url: localhost/about/css/app.css
On an nginx I fixed this as follows:
location ~ .(css|files|js|lib|partials)/(.+)$ {
try_files $uri $uri/ /$1/$2;
}
location / {
index index.html index.htm;
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404;
}
But I need to do it for Apache as well. The closest I get is :
RewriteCond %{REQUEST_URI} \.(lib|css|js|partials|files)$ [NC]
RewriteRule ^(.*)$ ./index.html/$1
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} –d
RewriteRule ^ - [L]
…And all kinds of variations to these rules but I can only get the files to load correctly from the homepage. I either don't get it to point to the right url or it does point to it but it doesn't actually load the files.
Surely lots of people implemented this before for an AngularJS application?
Thanks in advance, Arno