![](/img/trans.png)
[英].htaccess/mod_rewrite: running Angular app in sub-folder?
[英]mod_rewrite and mod_proxy together in Apache configuration
我正在使用Apache服務器來托管我的Angular應用程序。 所以我通過以下配置啟用了單頁面應用程序支持
<Location / >
RewriteEngine on#
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.html [L]
</Location>
我也有一個后端。 我正在使用mod_proxy來代理Apache。
ProxyPass "/api" "http://127.0.0.1:8081/api"
ProxyPassReverse "/api" "http://127.0.0.1:8081/api"
但是當我使用這兩種配置時,我無法調用任何API。 所有調用都返回index.html。
我可以知道出了什么問題以及如何解決這個問題嗎?
感謝@Dusan Bajic的評論。
現在,我有以下配置,它的工作原理。
ProxyPass "/api" "http://127.0.0.1:8081/api"
ProxyPassReverse "/api" "http://127.0.0.1:8081/api"
<Location / >
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/api
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule . /index.html [L]
</Location>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.