Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

node redirect

switch (req.url) {
    case "/":
      path += "index.html";
      break;
    case "/about":
      path += "about.html";
      break;
    case "/about-us":  // <--- redirection from /about-us to /about
      res.statusCode = 301;
      res.setHeader("Location", "/about");
      res.end();
      break;
    default:
      path += "404.html";
      res.statusCode = 404;
  }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #node #redirect
ADD COMMENT
Topic
Name
6+3 =