assistbss
assistbss

Reputation: 537

angular ui.router html5mode unable to reload in apache

I'm trying to remove '#' from urls.

Using link with ui-sref or href attributes navigation works properly, but accessing directly to the same url, or refreshing page or pressing enter into url bar of the browser i get 404 not found error.

I enabled html5 mode:

$locationProvider.html5Mode(true);

Added base tag in head before any inclusion:

<base href="/folder/" />

Here is .htaccess file content (copied from angular-ui faq):

RewriteEngine on

# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ /folder/index.html [L]

Seems to be a problem related to .htaccess file.

What is wrong?

Upvotes: 2

Views: 400

Answers (1)

assistbss
assistbss

Reputation: 537

I've to:

  1. enable AllowOverride in /etc/apache2/apache2.conf (enable AllowOverride)
  2. enable mod_rewrite, from terminal a2enmod rewrite
  3. restart apache from terminal service apache2 restart

Upvotes: 1

Related Questions