2017-12-14 17 views
0

angular2とsymfony3を持つアプリケーションを共有ホスティング(1 & 1)にアップロードしました。共有ホスティングのAngular2でのルーティング

これは、ウェブサイトである:http://s714578534.mialojamiento.es

それはhttp://s714578534.mialojamiento.es/inicioにリダイレクトし、それが良い動作します。

http://s714578534.mialojamiento.es/iniciohttp://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); 

任意のソリューション?ありがとう!

答えて

1

試みはあなたの.htacces

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

1&1では動作しませんが、他のサーバーで試してみましたが、完全に動作します。ありがとう!!! –

1

は、このラインにこの

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

これが簡単なソリューションです:) – albert

+0

それが動作を変更するには、それがルートに「#」を置きます。どうすれば削除できますか? –

+0

パラメータuseHash:falseを設定してハッシュを削除します –

0

ため

RouterModule.forRoot(appRoutes); 

を変更してみてくださいsymfonyはすべてのファイルと一致していない任意のURLをキャッチします。別のサブドメインへ

移動にsymfony:

http://[angular].mialojamiento.es

http://[symfony API]あなたが同様にサブフォルダを扱うことができます

を.mialojamiento.es:

http://[yourid].mialojamiento.es/api/app.php < --- symfonyの

http://[yourid].mialojamiento.es/ < ---角度

+0

私はこれを試しましたが、私はまだ同じ問題があります。私はhttp://s714578534.mialojamiento.esにアクセスすることができますが、http://s714578534.mialojamiento.es/loginにアクセスすることはできません –

+0

あなたはそれについての質問についてさらに詳しく説明できますか?両方のドメインの名前が同じであるため、複数のホストが必要な場合があります – albert

+0

.htaccessの問題は@habibunの回答を試してみます – albert

関連する問題