Я хочу создать приложение Angular, которое будет запущено на сервере Apache. Локально с npm start
он работает хорошо, но при удаленном Apache развертывании многие файлы отсутствуют. Я пытался настроить шрифты и файлы i18n в папке src/assets/....
в 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 (не найдено)
Так что после исследования похоже, что мне нужно добавить сопоставление, используя это: https://www.thewebflash.com/set-the-correct-mime-types-for-woff-fonts-in-your-web-server/, но оно не работает. Я также попытался добавить эту конфигурацию: https://gist.github.com/vmilev/cf8ef05c2d77fc8aedd6c5831d724a77
Но опять не повезло. Можете ли вы дать мне некоторое представление о том, как это можно исправить?
.htaccess файл
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteBase /angular/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
</IfModule>
AddType font/woff .woff
AddType font/woff2 .woff2