How do I create a 301 redirect - SISTRIX Login Free trialSISTRIX BlogFree ToolsAsk SISTRIXTutorialsWorkshopsAcademy Home / Ask SISTRIX / OnPage-Optimisation / HTTP Status Codes - Definition and Types / 3xx Redirection / Create a 301
How do I create a 301 redirect
From: SISTRIX Team 22.02.2022 3xx Redirection What Does Status Code 302 Mean? What's The Difference Between A 301 And A 302 Redirect? How do I create a 301 redirect Status Code 307 - What Is A 307 Temporary Redirect? How many 301 redirects in a row can I use? Setting up a 301-redirect from the non-www to the www. domain-name What Is A 301 Redirect? Back to overviewWith a 301 Redirect, a webserver returns the HTTP Status Code 301 to the requesting web client (browser) which could be Google-Bot, for example, or a user. This status code tells the client that the requested resource (a URL for example) has permanently moved and is now available on a new URL. It is good practice to keep pages redirected if their URL changes for any reason.ContentsContentsCreating a 301 redirect through htaccessCreating a 301 redirect in PHPCreating a 301 redirect with NGINX Lighttpd or Microsoft Internet Information Services IIS Creating a redirection via a WordPress pluginIs there a limit to how many 301 Permanent redirects I can do on a site Additional Information about this topic You can easily set up a 301 redirect in PHP or through the .htaccess file and the necessary mod_rewrite module, if you use an Apache Webserver. If you use WordPress and have no access to server files, it’s possible to install plugins that can manage and perform redirects for you. Information on an example WordPress redirection plugin is shown below. Creating a 301 redirect through htaccess
If you want to create a 301 redirect through the .htaccess file you need an Apache webserver and an activated mod_rewrite module. Considering that Apache is one of the most popular webservers, almost all big webhosts will use it. In addition, the mod_rewrite module is already activated in most cases. The .htaccess-file is also included per default in most webhosting bundles. The .htaccess file is found in the top-level directory of the web content but can also work within a subdirectory. Paste the following source code into the .htaccess-file:RewriteEngine On RewriteRule ^/directory/a-document.html https://www.domain.com/a-document.html [R=301] Function: By using the command “RewriteEnginge On” the mod_rewrite module of the Apache webserver will be activated. The second line of code starts with “Redirect 301” and defines the HTTP status code that is supposed to be returned. Next, specify the path of the document that is going to be redirected – such as “https://www.domain.com/directory/a-document.html”. Afterwards add a space and then type in the target URL onto the same line – the target URL is the URL you want to redirect the Google-Bot as well as the users to. In our example, the file “a-document.html” cannot be found at “/directory/” anymore, but one level higher up, at the domain root. Note that there are a number of redirect rules and syntax that can be used. One example is the permanent redirection of http to https. To permanently redirect http requests to https requests it is possible to intercept them using a port 80 redirection. Port 80 is the well know TCP port for non-encrypted traffic.RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L] Function: By capturing all requests arriving on the server port 80 they can be permanently redirected, with the correct and full URL to the https equivalent. For more information, read the introduction to the Apache mod_rewrite syntax and rules at the apache website. Creating a 301 redirect in PHP
If you want to create a 301 redirect in PHP the source document has to be a PHP file. If this is the case, the PHP code for the 301 redirect can be added directly into the document that should be redirected. Example: Paste the following source code in the first line of the document you want to redirect: Function: By using the above source code in the file “the-old-name.php”, which can be reached at “domain.com/the-old-name.php”, all visitors will now be redirected to the new source “domain.com/the-new-name.php“ (line 3) and the HTTP Status Code 301 moved permanently will be returned. Creating a 301 redirect with NGINX Lighttpd or Microsoft Internet Information Services IIS
Creating a 301 redirect on other webservers, like NGINX, Lighttpd or the IIS, is not as trivial for inexperienced users.301 redirects using NGINX301 redirects using Lighttpd301 redirects using IIS Creating a redirection via a WordPress plugin
As with any plugin one must remember these things.You introduce more code to your website. This can increase delays and decrease securityIf a plugin development is hacked, this code might reach your serverPlugins may change ownership, which may change the future stability or support for your pluginIf the development stops, the plugin may go out of date and you’re left with a migration problem to avoid future security or compatibility problemsIf you remove the plugin, all previous settings and entries may be lost One WordPress plugin to consider is redirection.me which is a mature and stable plugin used by many people. It’s free, there’s no paid version and it provides a simple interface with which one can manage redirects. redirection.me user interface as seen in WordPress Is there a limit to how many 301 Permanent redirects I can do on a site
Is there a limit to how many 301 Permanent redirects I can do on a site How about how many redirects I can chain together? Additional Information about this topic
Google Search Console Help: 301 Redirections From: SISTRIX Team 22.02.2022 3xx Redirection What Does Status Code 302 Mean? What's The Difference Between A 301 And A 302 Redirect? How do I create a 301 redirect Status Code 307 - What Is A 307 Temporary Redirect? How many 301 redirects in a row can I use? Setting up a 301-redirect from the non-www to the www. domain-name What Is A 301 Redirect? Back to overview German English Spanish Italian French