Showing
4 changed files
with
20 additions
and
9 deletions
@@ -11,10 +11,8 @@ const _ = require('lodash'); | @@ -11,10 +11,8 @@ const _ = require('lodash'); | ||
11 | const channelModel = require('../models/index'); | 11 | const channelModel = require('../models/index'); |
12 | 12 | ||
13 | exports.index = (req, res, next) => { | 13 | exports.index = (req, res, next) => { |
14 | - let channelType = req.path.substring(1) || 'boys'; | 14 | + let channelType = req.path.split('/')[1] || 'boys'; |
15 | 15 | ||
16 | - // 将woman转换为girls,以便model层进行处理 | ||
17 | - channelType === 'woman' ? channelType = 'girls' : null; | ||
18 | channelModel.getContent(channelType).then(data => { | 16 | channelModel.getContent(channelType).then(data => { |
19 | 17 | ||
20 | // channel为空不缓存 | 18 | // channel为空不缓存 |
@@ -91,3 +89,11 @@ exports.hasNewUserFloor = (req, res, next) => { | @@ -91,3 +89,11 @@ exports.hasNewUserFloor = (req, res, next) => { | ||
91 | res.send(data); | 89 | res.send(data); |
92 | }).catch(next); | 90 | }).catch(next); |
93 | }; | 91 | }; |
92 | + | ||
93 | + | ||
94 | +// 频道页301重定向 | ||
95 | +exports.redirect = (goUrl) => { | ||
96 | + return function(req, res) { | ||
97 | + res.redirect(301, goUrl); | ||
98 | + }; | ||
99 | +}; |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -const router = require('express').Router(); // eslint-disable-line | 9 | +const router = require('express').Router({strict: true}); // eslint-disable-line |
10 | const cRoot = './controllers'; | 10 | const cRoot = './controllers'; |
11 | 11 | ||
12 | // Your controller here | 12 | // Your controller here |
@@ -14,9 +14,12 @@ const channelController = require(`${cRoot}/index`); | @@ -14,9 +14,12 @@ const channelController = require(`${cRoot}/index`); | ||
14 | 14 | ||
15 | // 频道页路由 | 15 | // 频道页路由 |
16 | router.get('/', channelController.index); | 16 | router.get('/', channelController.index); |
17 | -router.get('/woman', channelController.index); | ||
18 | -router.get('/kids', channelController.index); | ||
19 | -router.get('/lifestyle', channelController.index); | 17 | +router.get('/woman', channelController.redirect('/girls/')); |
18 | +router.get('/girls/', channelController.index); | ||
19 | +router.get('/kids', channelController.redirect('/kids/')); | ||
20 | +router.get('/kids/', channelController.index); | ||
21 | +router.get('/lifestyle', channelController.redirect('/lifestyle/')); | ||
22 | +router.get('/lifestyle/', channelController.index); | ||
20 | router.get('/japanKorean', channelController.japanKorean); | 23 | router.get('/japanKorean', channelController.japanKorean); |
21 | router.get('/channel/isNewUserAjax', channelController.hasNewUserFloor); | 24 | router.get('/channel/isNewUserAjax', channelController.hasNewUserFloor); |
22 | 25 |
@@ -296,7 +296,7 @@ const getPackage = (req, res, next) => { | @@ -296,7 +296,7 @@ const getPackage = (req, res, next) => { | ||
296 | }; | 296 | }; |
297 | 297 | ||
298 | const redirectNewProduct = (req, res) => { | 298 | const redirectNewProduct = (req, res) => { |
299 | - return res.status(301).redirect(helpers.urlFormat(`/product_${req.params[0]}${req.params[2]}`, null, 'item')); | 299 | + return res.redirect(301, helpers.urlFormat(`/product_${req.params[0]}${req.params[2]}`, null, 'item')); |
300 | }; | 300 | }; |
301 | 301 | ||
302 | module.exports = { | 302 | module.exports = { |
@@ -19,8 +19,10 @@ module.exports = () => { | @@ -19,8 +19,10 @@ module.exports = () => { | ||
19 | switch (req.subdomains[0]) { | 19 | switch (req.subdomains[0]) { |
20 | case 'www': // 主站 | 20 | case 'www': // 主站 |
21 | case 'cdnsrcwww': // 主站的回源地址 | 21 | case 'cdnsrcwww': // 主站的回源地址 |
22 | - case 'new': // 原新版 | ||
23 | case 'shop': // 商家入驻 | 22 | case 'shop': // 商家入驻 |
23 | + break; | ||
24 | + case 'new': // 原新版 重定向到301 | ||
25 | + return res.redirect(301, helpers.urlFormat(req.url, null, 'www')); | ||
24 | case 'item':// 商品详情页 | 26 | case 'item':// 商品详情页 |
25 | if (/\/product_([\d]+)(.*)/.exec(req.url) !== null) { | 27 | if (/\/product_([\d]+)(.*)/.exec(req.url) !== null) { |
26 | req.url = `/product/product_${RegExp.$1}${RegExp.$2}`; | 28 | req.url = `/product/product_${RegExp.$1}${RegExp.$2}`; |
-
Please register or login to post a comment