【发布时间】:2015-04-06 07:03:19
【问题描述】:
我正在将应用程序从网站的根域迁移到子域。根域上的新应用程序是用 Meteor 编写的,并使用 Iron-router。为了避免破坏外部链接,我想将所有未被流星应用处理的 URL 301 重定向到子域。
我似乎无法弄清楚如何使用 Iron-router 来做到这一点。由于我正在执行 301 重定向,因此它是一个服务器路由(通过 {where: 'server'}),但是当我这样做时,通用路由优先于所有其他现有路由,即使它在我的路由文件。
版本:
流星 1.0.3.1
铁:路由器 1.0.7
Router.route('/', function () {
this.render('home');
});
Router.route('/about', function () {
this.render('about');
});
// Takes precedence over all above routes (due to server?)
Router.route('/(.*)', function () {
this.response.writeHead(301, {'Location': 'https://subdomain.thedomain.com/' + this.params[0]});
this.response.end();
}, {where: 'server'});
【问题讨论】:
标签: redirect meteor iron-router