如何在node.js中做url重写



我有这个url重定向规则-

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]

我需要这些规则在express.js我怎么能写在express和我使用环回。

在环回中有相同的问题。这个问题和你看到的问题很相似

加上这个链接通过github可能会有帮助

app.all('/*', function(req, res, next) {
// Just send the index.html for other files to support HTML5Mode
res.sendFile('index.html', { root: __dirname });
});

虽然我尝试了上面的方法和下面的方法,但在我的情况下都不起作用:

app.use(function(req, res) {
res.sendfile(__dirname + '/Public/index.html');});

最新更新