首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在节点.htaccess -server中使用http url重写

在节点.htaccess -server中使用http url重写
EN

Stack Overflow用户
提问于 2018-01-05 19:15:01
回答 1查看 971关注 0票数 0

我正在尝试在节点http-server上以生产模式运行angular应用程序。我使用Angular的html5模式从URL中删除了#,并在.htaccess文件中添加了URL重写规则,以使其在生产模式下运行。

它在apache服务器上工作得很好,但是在Linux VPS上配置它真的很痛苦,所以为了避免额外的痛苦,我试图使用node http-server来实现这个目的,但是.htaccess文件配置在这里不起作用。

如何为节点服务器编写类似的配置?

这是我的.htaccess配置

代码语言:javascript
复制
#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]
EN

回答 1

Stack Overflow用户

发布于 2018-01-05 19:36:30

htaccess文件是Apache配置文件。但是你可以像这样重定向到index.html:

代码语言:javascript
复制
http.get('*', function(req, res) {  
    res.redirect('http://example.com/index.html');
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48112459

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档