301 & 302 Redirects
Description
Correctly redirecting pages is important in SEO. The two main redirect status codes are 301 and 302: respectively permanent and temporary redirects
Example
app.get("/de/folder/page", function(request, response) { response.writeHead(301, { Location: "https://newtargetpage.com", Expires: new Date().toGMTString() }); response.end(); });
app.get("/de/folder/page", function(request, response) { response.writeHead(302, { Location: "https://newtargetpage.com", Expires: new Date().toGMTString() }); response.end(); });
Redirects can be set up via an entry in the htaccess file of the Apache server.This is a small text file that contains instructions for the server. If a client calls a URL that is to be redirected, the server receives the command to redirect the client to the new URL. The .htaccess file is loaded from the server each time a page is accessed.
Redirect /old-path/new.html /newpath/new.html ####All site to new site: Redirect 301 / https://newdomain.com/ #####Removing www RewriteEngine On RewriteCond %{HTTP_HOST} ^www.example.com RewriteRule (.*) https://example.com/$1 [R=301,L]