【发布时间】:2019-11-10 11:04:27
【问题描述】:
我想在 Apache 子目录中部署 Angular 应用程序。我添加了这个 .htaccess 配置:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /admin/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) index.html [NC,L]
</IfModule>
我使用这个命令编译代码:
ng build --prod --base-href /admin/
但是当我打开一个页面时,我得到了这个错误:
Error: Uncaught (in promise): e: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":404,"statusText":"Not Found","url":"http://185.185.185.185/admin/api/transaction_notes/unique_id/219","ok":false,"name":"HttpErrorResponse","message":"Http failure response for http://185.185.185.185/admin/api/transaction_notes/unique_id/219: 404 Not Found","error":"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /admin/api/transaction_notes/unique_id/219 was not found on this server.</p>\n<hr>\n<address>Apache/2.4.18 (Ubuntu) Server at 185.185.126.15 Port 80</address>\n</body></html>\n"}
你能给我一些建议,我该如何解决这个问题?
【问题讨论】:
-
哪一行,你能粘贴整个配置作为答案吗?
-
我测试了它,但它不起作用。
-
我会逐行删除,看看是哪一行导致了问题
标签: angular typescript apache mod-rewrite