Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs redirect to url

// In Express
router.get('*',function(req,res){  
    res.redirect('http://exmple.com'+req.url)
})
Comment

nodejs redirect to url

response.writeHead(301,
  {Location: 'http://whateverhostthiswillbe:8675/'+newRoom}
);
response.end();
Comment

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;
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: toast 
Javascript :: expo font 
Javascript :: nodemon install locally json file 
Javascript :: add background image react native 
Javascript :: angular server start command 
Javascript :: define value in js 
Javascript :: Make Floating label TextInput in react native 
Javascript :: javascript print to pdf 
Javascript :: Uncaught TypeError: document.getContext is not a function 
Javascript :: try catch with for loop in javascript 
Javascript :: how to print an array javascript 
Javascript :: react icon import 
Javascript :: browser tab switch event js 
Javascript :: javascript timestamp conversion 
Javascript :: cypress visible 
Javascript :: how to find max number in array javascript 
Javascript :: Format of fetch 
Javascript :: Detect the city on application launch via geolocation react native 
Javascript :: for loop on object js 
Javascript :: what is linter javascript 
Javascript :: node js log colors 
Javascript :: mongoose update subdocument by id 
Javascript :: change all a tag href javascript 
Javascript :: react setstate in another component 
Javascript :: Async return values 
Javascript :: js fetch status of 500 
Javascript :: react class components 
Javascript :: paragraph to single line in javascript 
Javascript :: react native style variable 
Javascript :: date format in moment js 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =