angularjs - How to remove hash from url angular app? -
it may duplicate question. have tried many solutions,no answer work me. using ui-router angular web app. using apache2 server serve angular app. using ubuntu. project code inside of folder \var\www\html\myapp here myapp application folder. have tried following
1 adding <base href="/myapp/">
head tag
2 adding $locationprovider.html5mode(true);
or $locationprovider.html5mode({ enabled: true, requirebase: false});
(tried both separately)
3 adding .htaccess
file following content
options +followsymlinks <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !index rewriterule (.*) index.html [l] </ifmodule>
and other content .htaccess file got google serve path.
have tried putting .htaccess file inside \var\www\html\ \var\www\html\myapp. remove hash url, when clicked refresh ,it show not found. can please me.
try in .htaccess
file under \var\www\html\myapp
:
rewriteengine on rewritecond %{http_host} ^example\.com$ [nc] rewriterule ^ http://www.%{http_host}%{request_uri} [l,r=301,ne] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^ index.html [l]
in index.html
head section :
<base href="/myapp/">
in app config :
$locationprovider.html5mode({ enabled: true, requirebase: false }); /* records full path */ $analyticsprovider.withbase(true);
Comments
Post a Comment