0

ルートの$locationProvider.html5Mode(true);および<base href="/" />を有効にした後、手動リロード後にクラッシュが開始されました。

ソリューションを探す私は、.htaccessのルールがこの問題を解決することがわかりましたが、さまざまな設定は役に立ちませんでした。

index.htmlはサブディレクトリに/views/index.html

.htaccessあるので、多分これは、次のとおりです。

Options +FollowSymLinks 

<ifModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} !index 
    RewriteRule (.*) index.html [L] # /views/index.html doesn't work as well 
</ifModule> 

route config

app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { 
    $locationProvider.html5Mode(true); 

    $routeProvider 
     .when('/', { 
      templateUrl: 'home.html', 
      controller: 'AddTaskCtrl', 
      controllerAs: 'AddTask' 
     }) 
     .when('/chat', { //this route breaks on manual refresh 
      templateUrl: 'chat.html', 
      controller: 'ChatCtrl', 
      controllerAs: 'chat' 
     }) 
}]); 

答えて

1

ステップ1:のみ$ locationPを使用rovider.html5Mode(true);

ステップ2:変更あなたの.htaccess

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^index.html [L] 

index.htmlには、あなたのアプリを指して負荷を開始するか、問題は `.htaccess`ファイルではありませんでしたが、より多くの方法https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

+0

を見ているときに、あなたのFAQへのリンクは非常に役に立ちました。ありがとうございました – lomboboo

関連する問題