[英]Using .htaccess url rewrite in node http-server
我正在嘗試在節點http-server上的生產模式下運行angular應用程序。 我使用Angular的html5模式從URL中刪除了#,並在.htaccess
文件中添加了URL重寫規則,以使其在生產模式下運行。
它在apache服務器上可以正常工作,但是在Linux VPS上配置它確實是一個很大的麻煩,因此,為了避免額外的麻煩,我試圖為此目的使用節點http-server,但是.htaccess
文件配置在這里不起作用。
如何為節點服務器編寫類似的配置?
這是我的.htaccess
配置
#Enable deep-linking for Angular2 routes - Redirect all calls to index.html
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
htaccess文件是Apache配置文件。 但是您可以像這樣重定向到index.html:
http.get('*', function(req, res) {
res.redirect('http://example.com/index.html');
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.