[英]Routing in Angular2 in a shared hosting
I have uploaded an application with angular2 and symfony3 in a shared hosting (1&1). 我已经在共享主机(1&1)中上载了带有angular2和symfony3的应用程序。
This is the website: http://s714578534.mialojamiento.es 这是网站: http : //s714578534.mialojamiento.es
It redirects to http://s714578534.mialojamiento.es/inicio , and it works good. 它重定向到http://s714578534.mialojamiento.es/inicio ,并且效果很好。
The problem is when I try to directly access to http://s714578534.mialojamiento.es/inicio , http://s714578534.mialojamiento.es/libros/1/Todos/Valoraci%C3%B3n , ... The website don't load. 问题是,当我尝试直接访问http://s714578534.mialojamiento.es/inicio , http://s714578534.mialojamiento.es/libros/1/Todos/Valoraci%C3%B3n ,...该网站唐不加载。
index.html 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);
Any solution? 有什么办法吗? Thanks!
谢谢!
try to change your .htacces 尝试更改您的.htacces
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
Try changing this line 尝试更改此行
RouterModule.forRoot(appRoutes);
for this 为了这
RouterModule.forRoot(appRoutes, { useHash: true });
Symfony will catch any URL that does not match any file. Symfony将捕获与任何文件都不匹配的任何URL。
Move symfony to another subdomain: 将symfony移至另一个子域:
http://[angular].mialojamiento.es http:// [angular] .mialojamiento.es
http://[symfony api].mialojamiento.es http:// [symfony api] .mialojamiento.es
You can work with subfolders as well: 您也可以使用子文件夹:
http://[yourid].mialojamiento.es/api/app.php <--- symfony http:// [yourid] .mialojamiento.es / api / app.php <--- symfony
http://[yourid].mialojamiento.es/ <--- angular http:// [yourid] .mialojamiento.es / <---角
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.