我正在尝试在节点http-server上以生产模式运行angular应用程序。我使用Angular的html5模式从URL中删除了#,并在.htaccess文件中添加了URL重写规则,以使其在生产模式下运行。
它在apache服务器上工作得很好,但是在Linux VPS上配置它真的很痛苦,所以为了避免额外的痛苦,我试图使用node 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]发布于 2018-01-05 19:36:30
htaccess文件是Apache配置文件。但是你可以像这样重定向到index.html:
http.get('*', function(req, res) {
res.redirect('http://example.com/index.html');
});https://stackoverflow.com/questions/48112459
复制相似问题