Angularjs HTML5 mode on doesnt work even after rewriting URLs on server side -
in angularjs
application '#' present in url. set html5 mode
app true , made necessary changes on application code urls. pfb code that.
app.config(function($locationprovider){ $locationprovider.html5mode({ enabled: true, requirebase: false }); });
now per this link made necessary changes in configuration file. changes follows:
options followsymlinks rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /$1 [l]
the problem:
the application still won't work , still doesn't refresh url i.e. still 404: page not found error.
please me regarding this.
well, setting requirebase: true
, inserting <base href="/">
(or ever else, depending on env) in header, , using settings
rewriteengine on rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule ^ - [l] # rewrite else index.html allow html5 state links rewriterule ^ index.html [l]
works me in every places ever used it. directoryindex
must set index.html
or name of file using , important, server must send initial file.
the following example, of i'm using right now, in pc, no public hosting.
<virtualhost 127.0.0.1:80> servername www.myproject.localhost documentroot "d:/work/myproject/" directoryindex index.html <directory "d:/work/myproject/"> options +followsymlinks rewriteengine on rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule ^ - [l] # rewrite else index.html allow html5 state links rewriterule ^ index.html [l] allowoverride allow require granted </directory> </virtualhost>
Comments
Post a Comment