Explorar el Código

use 301 redirect

guoziyun hace 1 año
padre
commit
ec19e516b7
Se han modificado 2 ficheros con 5 adiciones y 5 borrados
  1. 4 4
      routes/index.js
  2. 1 1
      views/header.ejs

+ 4 - 4
routes/index.js

@@ -268,7 +268,7 @@ router.get(/^\/(en|zh|es|pt|ja)$/, function (req, res, next) {  // 限制严格
 
 // 分类页不带tag,redirect 到 latest
 router.get('/:lang/category', (req, res, next) => {
-  return res.redirect(`${req.originalUrl}/latest`);
+  return res.redirect(301, `${req.originalUrl}/latest`);
 });
 
 // 分类页路由
@@ -659,7 +659,7 @@ router.get('/:lang/albums', function (req, res, next) {
 router.get('/:lang/album/:id', function (req, res, next) {
   const uri = req.originalUrl;
   let newUri = uri.replace('album', 'coloring-page-album');
-  res.redirect(newUri);
+  res.redirect(301, newUri);
 });
 
 // 专辑详情页路由
@@ -949,7 +949,7 @@ router.get('/:lang/coloring-page-video/:id', function (req, res, next) {
 router.get('/:lang/designers', function (req, res, next) {
   const uri = req.originalUrl;
   let newUri = uri.replace('designers', 'artists');
-  res.redirect(newUri);
+  res.redirect(301, newUri);
 });
 // 设计师专栏路由
 router.get('/:lang/artists', function (req, res, next) {
@@ -1045,7 +1045,7 @@ router.get('/:lang/artists', function (req, res, next) {
 router.get('/:lang/designer/:id', function (req, res, next) {
   const uri = req.originalUrl;
   let newUri = uri.replace('designer', 'artist');
-  res.redirect(newUri);
+  res.redirect(301, newUri);
 });
 // 设计师详情页路由
 router.get('/:lang/artist/:id', function (req, res, next) {

+ 1 - 1
views/header.ejs

@@ -17,7 +17,7 @@
         <a href="/<%= lang %>/videos" class="<%= uri.includes(`/${lang}/videos`) ? 'selected' : '' %>">
           <%= translate.videoPage[lang] %>
         </a>
-        <a href="/<%= lang %>/category" class="<%= uri.includes(`/${lang}/category`) ? 'selected' : '' %>">
+        <a href="/<%= lang %>/category/latest" class="<%= uri.includes(`/${lang}/category`) ? 'selected' : '' %>">
           <%= translate.categoryPage[lang] %>
         </a>
         <a href="/<%= lang %>/tag" class="<%= uri.includes(`/${lang}/tag`) ? 'selected' : '' %>">