GUIDE REDIRECT URLS CORRECTLY USING CPANEL AND HTACCESS 2020 -WAU

Home/Posts/Administración del Hosting/GUIDE REDIRECT URLS CORRECTLY USING CPANEL AND HTACCESS 2020 -WAU

Redirect urls

Due to the need to redirect web traffic, or to avoid being penalized in our positioning for showing duplicate content (same website loading from different parked domains), redirects are necessary and important when we work with the same domain with a different extension or we want to bring traffic to a single domain.

Redirects allow us to send all users who have access to a particular domain or page to a different URL from the same or an external host.

For example, if you have a very long URL that cannot be shortened, you can use redirection to add an address to a short URL. Users can access the content of the long URL through the short URL without affecting your SEO.

What is a Redirection?


A redirect > www it is a rule in your web server that transmits all the traffic of the web version without www from your domain to the version with www, or vice versa.

The HTTP protocol used on the web has a numerical system to identify the status of page requests. The status code 301 indicates that the requested page or resource has been “Permanently moved”.

Types of redirect error codes:

  • 300 Multiple Choices: More than one possible answer.
  • 301 Moved Permanently: The requested URI has changed.
  • 302 Not Found: The requested URI has temporarily changed.
  • 303 See Other (from HTTP / 1.1): The server will direct the client to another resource in another URI.
  • 304 Not Modified: The answer has not been modified. The cached version is still used.
  • 305 Use Proxy (from HTTP / 1.1): The destination or result will be accessible from a proxy, for security.
  • 306 unused: No longer used.
  • 307 Temporary Redirect (from HTTP / 1.1): The same semantics apply as in a 302, but the UserAgent cannot change the HTTP method used.
  • 308 Permanent Redirect: The resource has been permanently moved to another URI.

When applying, for example, a www redirect it is important that you return a 301 status code so that search engines know which URL should be indexed.

When migrating a website from one domain to another, it is very important that the links you built in your old domain are not broken. Proper redirection of all pages from the old domain, in the same location, to the new domain will ensure that visitors to the old domain end up in the right place.

A failure (Error 404) in this action it will cause a loss of visitors, as well as the penalty for search engine positioning.

These types of redirects can be done manually by adding code like the following to the .htaccess file:

RewriteEngine On RewriteCond %{HTTP_HOST} ^viejodominio.com$ [OR] RewriteCond %{HTTP_HOST} ^www.viejodominio.com$ RewriteRule (.*)$ http://www.nuevodominio.com/$1 [R=301,L]

What is the .htaccess file?


The file .htaccess is a “hidden” file (the. in front of the name indicates that it is a hidden file).

In order to view it you must:

  1. Access your cPanel.
  2. Go to the File Manager (it opens a dialog and one of the options is “Show hidden files” must be selected).
  3. Navigate to folder / public_html (where we interpret you have the web).
  4. There you can locate the file .htaccess (not to be confused with htaccess.txt which is visible).

It is important to ensure that mod_rewrite is enabled on your server (yes for Websites Are Us customers). Verify that the following line appears somewhere in your file .htaccess above the rule you are going to add:

RewriteEngine On

We assume that your web server uses Apache, so you should be able to add the mentioned lines to your file .htaccess located at the root of your website.

You can create rules that redirect URLs that have a certain pattern to a new location.

Since these redirects involve complex regular expressions, we don’t cover them in this article.

An SEO professional can help you create these more complex and specific rules for each situation. Just make sure you use a 301 redirect for relocated content.

Any other type of redirect will not preserve your rankings in the search engines.

Recommended reading:
Useful .htaccess codes for websites



How do I perform a Redirection from cPanel?


The process is simple and I leave it here summarized in steps:

  1. Access your Hosting Panel (cPanel), Domains, Redirect.
  2. Select the type of redirection you want to do from the menu Kind.
  • Option 1: Redirection 301 Permanent which will notify the visitor’s browser to update their records.
  • Option 2: Temporary 302 Redirection it will not update visitor bookmarks.
  • Choose ** All Public Domains ** (All Public Domains) or a specific domain name on the menu.
  • Use the option ** All Public Domains ** (All Public Domains) to redirect all domains in your cPanel.
  • In the text box to the right of the domain selection menu, enter the rest of the URL you want the server to redirect to.
  • For redirects, in the text box, type the URL you want to redirect users to (one).
  • Select one of the following options:
    • Redirection with www only redirects users who enter www in front of the page name.
    • Redirection with or without www. This option will redirect all users, regardless of whether the prefix www is included. in the URL.
    • Do not redirect users who enter www. in the URL.
  • Select the option Wildcard Redirect (Wildcard Redirect) if you want to redirect all the files inside a directory with the same file name in the new directory (2).
  • Click on Add.
  • one: You must specify a protocol in this text box. For example, http: //, https: // or ftp: //.

    2: For example, if you enable the redirect wildcard option and domain1.com redirects to domain.comso if a visitor tries to access the URL http://dominio1.com/imagen.jpg will be redirected to the URL http: // domain .com / image.jpg.

    A common case is to perform a 301 redirect if you want to redirect only the traffic of a certain page ancient to a new page, which you can do by adding to the file .htaccess the following code:

    Redirect 301 /ruta_antigua/antigua_pagina.htm http://www.dominio.com/nueva_pagina.htm

    Redirects should always be inserted at the beginning of the .htaccess file, either in the root folder of the Hosting or in the folder of the installation that will manage these redirects. If these redirects appear at the end of the .htaccess file, they will not work correctly.

    How do I remove a redirect?


    If for some reason it no longer makes sense to maintain a previously made Redirection, you can (and should) delete it so that your traffic and positioning are not affected. Remember that Google doesn’t like broken links (404).

    • Click the button for the redirect you want to remove.
    • To confirm that you want to remove the redirect, click Yes.
    • To keep the redirect, click No.

    Video


    In the following video I explain how to manage 301 Redirections from your Hosting Panel (cPanel).


    Remember that you must subsequently edit the .htaccess file on the web where you apply the redirection and move the redirection codes applied by cPanel to the top of the file itself so that they are the first thing Apache interprets.

    Conclusions


    Redirects put order in those urls that have changed over time, have disappeared because the contents were removed or simply are not reachable for any reason not discussed in this article.

    Always make 301 redirects, especially if you detect that you have 404 errors in your tool Tracking Errors in Google Search Console.




    By |2020-05-12T01:09:48+00:00May 12th, 2020|Administración del Hosting|