Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Angular route with html5Mode giving 'Not found' page after reload

I made some Angular routes as shown in the code bellow.

app.config(function($routeProvider, $locationProvider, $provide) {
    .when('/', {
         templateUrl: 'home.html',
         controller: 'AppCtrl'
    .when('/portfolio', {
        templateUrl: 'portfolio.html',
        controller: 'AppCtrl'
    $provide.decorator('$sniffer', function($delegate) {
         $delegate.history = historyCompatCheck();
         return $delegate;

This works fine, after i set the base href to be "/" it accepted an anchor with the href of "/portfolio", but when i go to "http://url.com/portfiolo" or try to reload the page when i'm on the portfolio route it will give me an server error. Can i do something about this?

Thanks in advance.

like image 241
jvakuiler Avatar asked Mar 23 '23 15:03


1 Answers

I solved it myself.. you always need to make a .htaccess file in the root of your project. Containing the following:

 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
like image 184
jvakuiler Avatar answered Mar 25 '23 05:03