Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法从Apache服务器上部署的angular应用加载文件_Angular_Apache_Angular8_Mime Types_Angular9 - Fatal编程技术网

无法从Apache服务器上部署的angular应用加载文件

无法从Apache服务器上部署的angular应用加载文件,angular,apache,angular8,mime-types,angular9,Angular,Apache,Angular8,Mime Types,Angular9,我想创建一个在Apache服务器上运行的Angular应用程序。从npm start本地运行,运行良好,但从远程Apache部署来看,许多文件丢失。我试图将文件夹src/assets/…下的字体和i18n文件配置为angular.json: "assets": [ "src/favicon.ico", "src/assets", "src/web.config" ]

我想创建一个在Apache服务器上运行的Angular应用程序。从
npm start
本地运行,运行良好,但从远程Apache部署来看,许多文件丢失。我试图将文件夹
src/assets/…
下的字体和i18n文件配置为
angular.json

            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/web.config"
            ],
但当我运行网页时,会出现如下错误:

633328.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
materialdesignicons-webfont14e6.woff2:1 Failed to load resource: the server responded with a status of 404 (Not Found)
fontawesome-webfont3295.woff2:1 Failed to load resource: the server responded with a status of 404 (Not Found)
fontawesome-webfont3295.woff:1 Failed to load resource: the server responded with a status of 404 (Not Found)
materialdesignicons-webfont14e6.woff:1 Failed to load resource: the server responded with a status of 404 (Not Found)
fontawesome-webfont3295.ttf:1 Failed to load resource: the server responded with a status of 404 (Not Found)
materialdesignicons-webfont14e6.ttf:
1加载资源失败:服务器响应状态为404(未找到)

所以在研究之后,我似乎不得不用这个来添加映射:但它不起作用。我还尝试添加此配置:

但同样没有运气。你能告诉我怎么解决这个问题吗

.htaccess文件

重新编写引擎打开
#如果请求了现有资产或目录,请按原样转到该资产或目录
RewriteCond%{DOCUMENT_ROOT}%{REQUEST_URI}-f[或]
重写cond%{DOCUMENT\u ROOT}%{REQUEST\u URI}-d
重写规则^-[L]
#如果请求的资源不存在,请使用index.html
重写规则^/index.html
选项索引跟随符号链接
重新启动发动机
基线/角度/
重写规则^index\.html$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。index.html[L]
AddType字体/woff.woff
AddType字体/woff2.woff2

只需在URL之前添加styles.css中的斜杠即可。从此改变

angular/assets/fonts/glyphicons-halflings-regular.eot
对此

/angular/assets/fonts/glyphicons-halflings-regular.eot

是否不管文件是否存在,都会将所有URL重定向到
index.html
?您应该有一个检查
-f
(文件)或
-d
(目录)的
RewriteCond
。您可以发布相关的Apache配置吗?我使用默认的Apache配置,并添加了.htaccess文件。查看更新的端口。您的.htaccess看起来不太正确。您应该至少正确地转到文件或目录,但随后您要重写到index.html,并添加一个全新的重写块?在这个块中,您总是重写base,并且总是重写到index.html,因为
[L]
而停在那里,然后还有更多无法实现的重写。也许第二个
重写引擎打开时会删除以前的规则,这会导致奇怪的行为?谢谢。到目前为止还不错,但现在我发现“无法解码下载的字体:
/angular/assets/fonts/glyphicons-halflings-regular.eot