2016-06-10 2 views
2

밀어 넣기 상태를 구현하기위한 지침을 codelord.net"에 따라 수행하고 .htaccess 코드를 here에서 가져 왔습니다.아파치에 각도 밀어 넣기 상태를 구현하는 방법

탐색 링크를 클릭하면 URL이 올바르게 보이지만 (http://writers-tryst-test.ron-tornambe.com/about) 홈 페이지에는 빈 페이지가 표시되고 나머지 페이지에는 404 페이지가 표시되지 않습니다.

저는 리눅스 초보자이며 .htaccess 루트 파일의 위치에 대해 약간 혼란 스럽습니다. 나는 GoDaddy 공유 서버에있다. public_html을 포함하는 동일한 폴더에있는 .htaccess 파일에 코드를 추가했습니다.

htaccess로 편집 - 새 파일

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{HTTPS} off 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 
<IfModule mod_rewrite.c> 
     RewriteEngine on 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteRule ^(.*)$/[L,QSA] 
</IfModule> 

각도 JS

angular.module('wtApp').config(function($locationProvider) { 
    $locationProvider.html5Mode(true); 
}); 
var wtApp = angular.module('wtApp', ['ngRoute']) 

wtApp.config(function ($routeProvider) { 
    $routeProvider 
    // route for the home page 
    .when('/', { 
     templateUrl: 'pages/home.html', 
     controller: 'mainController' 
    }) 
    // route for the writers page 
    .when('/writers', { 
     templateUrl: 'pages/writers.html', 
     controller: 'writersController' 
    }) 

... HTML

<base href="/" /> 
,

또한 href의 앞에 슬래시 (/)를 붙이기도했습니다.

   <div class="collapse navbar-collapse" id="Writers-Tryst"> 
        <ul class="nav navbar-nav"> 
         <li class="active"><a id="homepage" href="/"><i class="glyphicon glyphicon-home"></i> Home</a></li> 
         <li><a href="writers" class="glyphicon glyphicon-book"> Writers</a></li> 
         <li><a href="enablers" id="enablers-link" class="glyphicon glyphicon-thumbs-up"> Enablers</a></li> 
         <li><a href="about" class="glyphicon glyphicon-info-sign"> About</a></li> 
         <li><a href="privacy" class="glyphicon glyphicon-info-sign"> Privacy/Rules</a></li> 
         <li><a href="contact" class="glyphicon glyphicon-envelope"> Contact</a></li> 
        </ul> 

답변

1

당신의 재 작성은 엉망입니다. 이 같은 이상한 물건을 얻기 : http://writers-tryst-test.ron-tornambe.com/writers-tryst-test.ron-tornambe.com/#//

을 지금, 나는이 내 자신의 버전에 근무, 나는 아파치 설정에서 디렉토리를 사용하여 종료 :

<Directory "S:/localhost/Apache24/Angular/routing-simple-evo"> 
    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] 
</Directory> 

난 당신이 디렉토리 안에 무엇이 붙여 넣을 수 있다고 생각 원하는 경우 태그를 htaccess에 넣으십시오. 그러나 어떤 이유로 설정 파일이 가장 잘 작동하는 것 같았습니다. 또는 마침내이 파일을 정렬 할 때 작동했던 것이었습니다.

내가 지적한 유일한 다른 점은 라우팅 명령의 순서와 그룹이 내가 본 오늘의 모든 자습서와 다르게 보입니다. 다음은 나를 위해 일한 것입니다 :

RoutingEvo.run([ 
    '$rootScope', 
    function($rootScope) { 
    // see what's going on when the route tries to change 
    $rootScope.$on('$locationChangeStart', function(event, newUrl, oldUrl) { 
     // both newUrl and oldUrl are strings 
     console.log('Starting to leave %s to go to %s', oldUrl, newUrl); 
    }); 
    } 
]); 

// create the controller and inject Angular's $scope 
RoutingEvo.controller('mainController', function($scope) { 
    // create a message to display in our view 
    $scope.message = 'Everyone come and see how good I look!'; 
}); 

RoutingEvo.controller('aboutController', function($scope) { 
    $scope.message = 'Look! I am an about page.'; 
}); 

RoutingEvo.controller('contactController', function($scope) { 
    $scope.message = 'Contact us! JK. This is just a demo.'; 
}); 

나는 다음에서 주로 이것을 함께 넣어 :

https://scotch.io/tutorials/single-page-apps-with-angularjs-routing-and-templating

https://scotch.io/tutorials/pretty-urls-in-angularjs-removing-the-hashtag

// create the module and name it RoutingEvo 
// also include ngRoute for all our routing needs 
var RoutingEvo = angular.module('RoutingEvo', ['ngRoute']); 

// configure our routes 
RoutingEvo.config(function($routeProvider, $locationProvider) { 
    $locationProvider.html5Mode(true); 

    $routeProvider 

     // route for the home page 
     .when('/', { 
      templateUrl : 'http://angular.dev/routing-simple-evo/views/home.html', 
      controller : 'mainController' 
     }) 

     // route for the about page 
     .when('/about', { 
      templateUrl : 'http://angular.dev/routing-simple-evo/views/about.html', 
      controller : 'aboutController' 
     }) 

     // route for the contact page 
     .when('/contact', { 
      templateUrl : 'http://angular.dev/routing-simple-evo/views/contact.html', 
      controller : 'contactController' 
     }); 
}); 

가 // 라우팅에서 약간의 정보를 기록

----- 올드 --------

앱의 루트 폴더에있는 .htaccess 파일에 .htaccess 파일이없는 경우 다음을 추가하십시오.

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$/[L,QSA] 
</IfModule> 
+0

감사합니다. Rob,하지만 페이지를 다시로드 할 때 HTTP 404 (GET/accounts)가 표시됩니다. –

+0

답변을 포함하는 htaccess 파일을 추가했습니다. 첫 번째

+0

모듈이 없거나 활성화되어 있지 않은 경우에만. 실제 코드에 About 라우트가 구성되어 있다고 가정합니까? ... –