0

I am getting some link failure error while reloading the page using Angular.js and .htaccess. Actually i was trying to remove hash tag in angular.js. I set .htaccess file and set the base href . I am explaining my code below.

.htaccess:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /Gofasto/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !.*\.(css|js|html|png|jpg|jpeg|gif|txt)
    RewriteRule (.*) index.html [L]
</IfModule>

loginRoute.js:

var Admin=angular.module('Channabasavashwara',['ui.router']);
Admin.config(function($stateProvider, $urlRouterProvider,$locationProvider) {
    $urlRouterProvider.otherwise('/');
    $stateProvider
     .state('/', {
            url: '/',
            templateUrl: 'dashboardview/login.html',
            controller: 'loginController'
        })
        .state('dashboard', {
            url: '/dashboard',
            templateUrl: 'dashboardview/dashboard.html',
            controller: 'dashboardController'
        })
        .state('dashboard.profile', {
        url: '/profile',
        templateUrl: 'dashboardview/profile.html',
        controller: 'profileController'
    })
    .state('dashboard.dept', {
        url: '/dept',
        templateUrl: 'dashboardview/dept.html',
        controller: 'deptController'
    })
    .state('dashboard.princpal', {
        url: '/princpal',
        templateUrl: 'dashboardview/princpal.html',
        controller: 'princpalController'
    })
    .state('dashboard.dept_head', {
        url: '/dept_head',
        templateUrl: 'dashboardview/depthead.html',
        controller: 'deptheadController'
    })
    $locationProvider.html5Mode({
      enabled: true,
      requireBase: true
    });

})

when i am in dashboard page its working fine.but when i am in profile page 1st time its working fine and when i am reloading this page again i am getting the following error.

failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/controller/profileController.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/controller/deptController.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/controller/deptheadController.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/js/newbill.js Failed to load resource: the server responded with a status of 404 (Not Found)
profile:118 Uncaught TypeError: $(...).chosen is not a function
http://localhost/Gofasto/dashboard/css/bootstrap.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/style22.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/plugins.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/pace.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/style.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/icons/font-awesome/css/font-awesome.min.css Failed to load resource: the server responded with a status of 404 (Not Found)

All my css and js folders are present inside Gofasto folder but it is showing the wrong link where 1st time it is coming properly.I also set <base href="/Gofasto/">in the index page.Please help me to resolve this error.

2
  • What are the correct paths of those files? Commented Oct 11, 2015 at 10:53
  • @Nerdwood : http://localhost/Gofasto/css/style.css this should be the path. Commented Oct 11, 2015 at 13:22

1 Answer 1

2

Try using an absolute path when referring to the resources, eg:

<link rel="stylesheet" type="text/css" href="/Gofasto/css/style.css">

... or:

<link rel="stylesheet" type="text/css" href="/css/style.css">

... instead of:

<link rel="stylesheet" type="text/css" href="css/style.css">
Sign up to request clarification or add additional context in comments.

7 Comments

@ Nerdwood : No,i did as per you but the links are not coming at all even from begining.
Do you have a public version of the website, or just the localhost version? Would be very useful to check it out.
@ Nerdwood : only localhost.
Can you please show how you are including the resources (e.g. CSS)?
@ Nerdwood : <link href="css/style.css" rel="stylesheet"> <link href="css/plugins.css" rel="stylesheet"> in this way its coming and problem is happening as per my explanation in post.When i did as per you it was not coming at all.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.