Authored by 周少峰

redirect

@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 * @date: 2016/6/16 4 * @date: 2016/6/16
5 */ 5 */
6 'use strict'; 6 'use strict';
  7 +const helpers = global.yoho.helpers;
7 8
8 module.exports = () => { 9 module.exports = () => {
9 return (req, res, next) => { 10 return (req, res, next) => {
@@ -11,6 +12,9 @@ module.exports = () => { @@ -11,6 +12,9 @@ module.exports = () => {
11 guangReg = /^\/guang/, 12 guangReg = /^\/guang/,
12 guangDetailReg = /.html$/; 13 guangDetailReg = /.html$/;
13 14
  15 + if (req.subdomains.length > 1) {
  16 + res.redirect(helpers.urlFormat(req.path, req.query, req.subdomains[0]));
  17 + }
14 if (req.subdomains.length) { 18 if (req.subdomains.length) {
15 switch (req.subdomains[0]) { 19 switch (req.subdomains[0]) {
16 case 'www': // 主站 20 case 'www': // 主站