2017-12-14 2 views
0

angular2 및 symfony3이 포함 된 응용 프로그램을 공유 호스팅 (1 & 1)에 업로드했습니다. 공유 호스팅에서 Angular2로 라우팅

는 웹 사이트입니다 : http://s714578534.mialojamiento.es

그것은 http://s714578534.mialojamiento.es/inicio로 리디렉션, 그리고 그것을 잘 작동합니다.

http://s714578534.mialojamiento.es/inicio, http://s714578534.mialojamiento.es/libros/1/Todos/Valoraci%C3%B3n에 직접 액세스하려고하면 문제가 발생합니다 ... 웹 사이트가로드되지 않습니다.

index.html을

<!doctype html> 
<html lang="es"> 
<head> 
    <meta charset="utf-8"> 
    <title>Conectando Lectores</title> 
    <base href="/"> 
    <meta name="description" content="Free Web tutorials"> 
    <meta name="keywords" content="Red Social, Literatura, Libros, Libro, Microcuento, Microcuentos, Autores, Autor, Autora, Lectura, Leer"> 
    <meta name="author" content="José Manuel Vázquez Crespo"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="icon" type="image/x-icon" href="favicon.ico"> 
</head> 
<body> 
    <app-root>Cargando...</app-root> 
</body> 
</html> 

app.routing.ts

const appRoutes: Routes = [ 
// Ruta de inicio de la aplicación 
{ path: '', redirectTo: 'inicio', pathMatch: 'full'}, 
// Otras rutas 
{ path: 'inicio', component: DefaultComponent }, 
{ path: 'login', component: LoginComponent }, 
{ path: 'login/:id', component: LoginComponent }, 
{ path: 'login/:email/:verificationKey', component: LoginComponent }, 
{ path: 'login/:id/:email/:verificationKey', component: LoginComponent }, 
{ path: 'registro', component: RegisterComponent }, 
{ path: 'perfil', component: PerfilComponent }, 
{ path: 'perfil/:username', component: PerfilComponent }, 
{ path: 'perfil/:username/:type', component: PerfilComponent }, 
{ path: 'mibiblioteca', component: LibraryComponent }, 
{ path: 'usuarios', component: UsuariosComponent }, 
{ path: 'mensajes', component: PrivateMessageComponent }, 
{ path: 'mensajes/:username', component: PrivateMessageComponent }, 
{ path: 'notificaciones', component: NotificationComponent }, 
{ path: 'politicaprivacidad', component: PoliticaPrivacidadComponent }, 
{ path: 'terminosycondiciones', component: TerminosyCondicionesComponent }, 
{ path: 'contacta', component: ContactaComponent }, 
{ path: 'noticias', component: NewsComponent }, 
{ path: 'noticias/:title', component: NewsComponent }, 
// Books 
{ path: 'libros', redirectTo: '/libros/1/Todos/Valoración', pathMatch: 'full' }, 
{ path: 'libros/:page/:genre/:order/:title', component: LibrosComponent }, 
{ path: 'libros/:page/:genre/:order', component: LibrosComponent }, 
{ path: 'libros/:page/:titulo', component: LibrosComponent }, 
{ path: 'libros/:titulo', component: VisualizarlibroComponent } 
]; 

export const appRoutingProviders: any[] = []; 
export const routing: ModuleWithProviders = 
RouterModule.forRoot(appRoutes); 

모든 솔루션? 감사! 모든 파일과 일치하지 않는 URL을 잡을 것이

RouterModule.forRoot(appRoutes, { useHash: true }); 

답변

1

시도는 .htacces

Options -MultiViews 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.html [QSA,L] 
+0

1 & 1에서는 작동하지 않지만 다른 서버에서 시도했지만 완벽하게 작동합니다. 감사 !!! –

1

보십시오. 다른 하위 도메인에

이동 심포니 :

http://[angular].mialojamiento.es

http://[symfony API는] .mialojamiento.es

당신은뿐만 아니라 하위 폴더로 작업 할 수 있습니다 :

http://[yourid].mialojamiento.es/api/app.php < --- 심포니

http://[yourid].mialojamiento.es/ < --- 각

+0

이 쉬운 솔루션입니다 :) – albert

+0

이 작동을 변경할 수 있지만 경로에 '#'을 넣습니다. 어떻게 삭제합니까? –

+0

매개 변수 useHash : false를 설정하여 해시를 제거합니다. –

0

심포니이 줄을

RouterModule.forRoot(appRoutes); 

을 변경

+0

이 작업을 시도했지만 여전히 동일한 문제가 있습니다. http://s714578534.mialojamiento.es에 액세스 할 수 있지만 http://s714578534.mialojamiento.es/login에 액세스 할 수 없습니다. –

+0

질문에 대한 자세한 내용을 추가 할 수 있습니까? 두 도메인 모두 같은 이름이므로 여러 개의 호스트가 필요할 수도 있습니다 – albert

+0

.htaccess와 함께 문제가 있다고 생각합니다 @habibun의 답변을 시도하십시오 – albert

관련 문제