13

Question: how to configure .htaccess in spring boot?

angularjs provides html5Mode, which makes your app use pushstate-based URL instead of hashtags. However this requires server side support, since the generated urls need to be rendered properly as well.

If you're running your angular app on an apache server you can easily add this rule in an .htaccess file.

# Apache .htaccess

# angularjs pushstate (history) support:
# See http://www.josscrowcroft.com/2012/code/htaccess-for-html5-history-pushstate-url-routing/
<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !index
    RewriteCond %{REQUEST_URI} !.*\.(css¦js|html|png) #Add extra extensions needed.
    RewriteRule (.*) index.html [L]
</ifModule>
Michael Petch
  • 43,801
  • 8
  • 98
  • 174
Igor Roman
  • 191
  • 2
  • 7
  • 2
    See my answer here: http://stackoverflow.com/questions/30859231/angular-html5-urls-server-configuration/37878557#37878557 – Christian Laakmann Jun 17 '16 at 10:00
  • 1
    Does this answer your question? [Angular HTML5 URLs - Server configuration](https://stackoverflow.com/questions/30859231/angular-html5-urls-server-configuration) – Scott Frederick Oct 28 '20 at 14:31

0 Answers0