angular - 如何在线发布 Angular 项目?index.html 文件管理
问题描述
我有一个网站的角度项目。该网站使用 PHP 与在线数据库进行通信。
我上传了 PHP 文件并且与数据库的通信正常。现在我正在尝试上传角度前端,但我遇到了一些问题。
如果我尝试使用 example.com 搜索我的网站,我会收到此错误:“禁止访问,您无权访问此资源。”
这就是我所做的:
我在我的角度项目中打开了 cmd.exe 并使用ng build --prod对其进行了编译
我获取了创建的dist文件夹的内容,并使用FileZilla将其上传到我的Aruba空间
我上传了包含以下内容的文件 .htaccess:
RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule 上的 RewriteEngine。$ - [NC,L] 重写规则 ^(. ) /index.html [NC,L]
可能我的问题与 index.html 有关。网站的第一页应该是 login.component.html,我的 index.html 在我的编码过程中从未改变过。
这是我的 index.html:
<!doctype html>
<html lang="it">
<head>
<meta charset="utf-8">
<title>Angular</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="mat-typography">
<app-root></app-root>
</body>
</html>
这是我的 app-routing.modules.ts:
import { NgModule } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { RouterModule, Routes } from '@angular/router';
import { AdminComponent } from './admin/admin.component';
import { HomeComponent } from './home/home.component';
import { LoginRegisterComponent } from './login-register/login-register.component';
import { NuovoPiattoComponent } from './admin/nuovo-piatto/nuovo-piatto.component';
import { VotiComponent } from './admin/voti/voti.component';
import { NuovoIngredienteComponent } from './admin/nuovo-piatto/nuovo-ingrediente/nuovo-ingrediente.component';
import { VotoComponent } from './home/voto/voto.component';
const routes: Routes = [
{
//first page
path: '',
component: LoginRegisterComponent
},
{
path: 'home',
component: HomeComponent
},
{
path: 'admin',
component: AdminComponent
},
{
path: 'admin/nuovo-piatto',
component: NuovoPiattoComponent
},
{
path: 'admin/voti',
component: VotiComponent
},
{
path: 'admin/nuovo-piatto/nuovo-ingrediente',
component: NuovoIngredienteComponent
},
{
path: 'home/voto',
component: VotoComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
我什至没有触摸 app.component.html / .ts 文件。
你能帮助我吗?
解决方案
推荐阅读
- c++ - 在运行时禁用系统错误弹出窗口(DLL 依赖项)
- serverless-framework - 创建自定义无服务器模板时,“ServerlessError: serverless.yml not found”错误
- java - 如何在片段中的方法中膨胀布局
- android - playTogether(x,y) 和 play(x).with(y) 有什么区别?
- java - 如何使用 selenium 指向表格并从网站下载 csv 文件
- depth-first-search - 如何使用 DFS 和 BFS 访问有向图?
- python - Python计数行csv中的唯一值
- javascript - 我怎样才能通过加载屏幕?
- jenkins - 詹金斯:如何发送邮件,其中包含过去一周内运行的所有工作的详细信息
- angular - MatTabNavBar 不显示箭头