All In One About 301 Redirection
INTRODUCTION
301 redirects often confuse websites owners and create a constant debate about best practices within SEO. With this in thought, this article will explain what a 301 redirect is, why and how you should use 301 redirects for your website. Here it’s the things you need to know about 301 redirections today.
WHAT IS A 301 REDIRECT?
A 301 redirect is a permanent redirect from one website URL to another URL linking to the initial website. 301 redirects send search engines and site visitors to URLs other than those initially written in their browser or selected from a search results page.
These 301 redirects also connect multiple website URLs under one roof, so that different search engines classify all website addresses by the domain authority of the inbound links.
Let’s put it into practice. Here are two different URLs that lead you to the same website. This is due to a 301 redirect: When people refer to Example blogs, with one of the URLs, the URL we use to drive blog traffic (blog.Example.com) preserves the authority of the search engine looking for inbound links to one of the URLs.
blog.example.com
http://blog.example.com
You should notice that the second link is “http: //” at the beginning of the URL, but until you reach the blog, the URL of your browser is “blog.hubspot.com”? This is due to a 301 redirect. It is important to configure this so that the domain authority of the incoming links to the http: // address is linked to blog.hubspot.com to improve the ranking in search engines.
HOW TO REDIRECT YOUR WEBSITE?
A 301 redirect can also be referred to as a command that tells search engines that a page has been moved permanently and that they index the new page and remove the previous page from their index.
Think of it as a change to the web address map. As long as everything is done right, the 301 redirection ensures that it preserves the rankings received from the previous page and avoids duplicate content that could occur when the engines index both versions of your site.
It’s not that hard to implement, and you should keep your search engine rankings for that particular page. If you need to change the name of the files or move the pages, this is the safest option. The code “301” is the same as “Moved Permanently.”
HERE ARE SEVERAL WAYS TO IMPLEMENT URL REDIRECTION
Let’s see how to do in PHP Redirect
- To start setting up a 301 redirect for your PHP site, sign in to the website’s FTP account.
- Open the Index.php file from your root directory.
- Replace the content with the following code:
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: &;lt;http://example.com/new-location&;gt;”); exit();
This fragment can also be consolidated in the following single line:
<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.new-url.com” );
?>
ASP.NET Redirect
Use the script as a reference to redirect the domain. The script has rules to redirect domain and a default action if no previous rule has been applied.
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”http://www.new-url.com”);
}
</script>
Replace the “new-url” text with the corresponding domain / URL. Make sure to not include “www” for any of your domain after “case.” Then save the script you created as “default.aspx”, you should then upload the file to your web space root.
JSP (Java) Redirect
To perform a 301 redirect to JSP pages, edit the code below for to suit your own purposes and place it on the web page you want to redirect:
<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.new-url.com/” );
response.setHeader( “Connection”, “close” );
%>
Ruby on Rails Redirect
Add this code to your web space
def old_action
headers[“Status”] = “301 Moved Permanently”
redirect_to “http://www.new-url.com/”
end
Redirect To www Using Htaccess Redirect
You can also perform the 301 redirect using the .htaccess file, Note that this approach is usually oriented towards advanced users and must be done carefully to work properly.
- To start modifying your .htaccess file
- Log into the FTP account.
- Open the .htaccess file from your home directory.
- Replace the contents with the following code:
This code redirects your entire site to a different domain
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Important Note: Make sure that the contents of the modified file are entirely removed before inserting the new code. As a reminder, we recommend backing up the original file if there is a problem running the redirection. This allows you to retry and finish the process if necessary.
WHY WE USE OR SETUP 301 REDIRECTION CODE?
The article I’ve provided so far focus on moving a page from one URL to your website to another. However, the 301 redirects can be used in a variety of other scenarios, including:
Moving to a new domain (Like Example.biz which is going to be redirected to Example.com).
Prevent Duplicate Content Issues, For example, if you have written multiple blogs on the same topic and want to add them to one blog.
Clean dynamic URLs and redirect them to shorter, more user-friendly versions for search engines.
WHERE CAN YOU FIND 301 REDIRECT CODE GENERATORS?
- The code generator supports the redirection of HTML, PHP, Asp, ASPX web pages and redirection of .htaccess files.
https://www.rapidtables.com/web/tools/redirect-generator.html
- This online tool allows you to create Redirect codes on the popular Apache server, which most hosting provider CMS systems like WordPress, Joomla, and Magento, are usually of this type of server.
https://websiteadvantage.com.au/HtAccess-301-Redirect-Generator
- Redirect Code Generator tool allows you to create a redirect page from one another. Of course, the website that contains sneaky has produced no reorienting details of accuracy and quality.
https://www.searchenginegenie.com/301-redirect-code-generator-tool.php
- You can use “Redirect Generator” service to create a personal 301 redirecting code. Use it to make sure your site does not lose Google loyalty and search engine rank.
In most cases, your site must use a .htaccess file.
https://webworkshop.net/seo-tools/301-redirect-generator
- The tool is very effective in creating 301 redirecting codes for your websites.