GUIDE 301 REDIRECTS HOW TO GO FROM FOLDER TO SUBDOMAIN? 2020 -WAU

Home/Posts/Administración del Hosting/GUIDE 301 REDIRECTS HOW TO GO FROM FOLDER TO SUBDOMAIN? 2020 -WAU

301 redirects

We all know what gives of itself .htaccess, and we have documented it several times, talking about the classic 301 redirects that from this file you can manage, without neglecting the possibilities it has to protect a website, etc.

When you started your web project, you were still learning to swim in this binary sea and you were not clear about how everything was going to be, what would be the structure of your website and how you had to organize your hosting, remember?

Months have passed, maybe some other year and now that you have learned a lot about hosting, websites and mainly SEO and some positioning, you have come to the conclusion that your website in a folder type http://yourdomain./blog It does not pay and what is cool is working from a subdomain type blog.yourdomain.com How do we fix this and that the positioning does not suffer?

Mainly redirecting, since it is the key to tell Google and other search engines such as Bing, Yahoo, etc., (let’s not forget them), that your internal links or the URI have changed and that what was previously accessible from a specific url that pointed to a sub-folder of your Hosting, with its corresponding internal links, will now be accessible from another very different url, that of a subdomain, but where internal links do not they’ve changed.

Summary process for targeting a subdomain:

  1. Make a backup, for the sake of the harvest!

  2. Edit the .htaccess file of the affected installation.
  3. Add the 301 redirect corresponding, explained below.
  4. Save changes to .htaccess file
  5. Clear your browser’s cache well.
  6. Forward your sitemap to the seekers.
  7. Verify that the web and internal links now load well from the subdomain.

This supposedly you should already have it declared in your hidden file .htaccess if you already had other redirects applied. You can skip it if it’s already declared in .htaccess.

RewriteEngine On RewriteBase /

This code allows you to redirect a website that you already had running and indexed from the folder yourdomain.com/blog towards a subdomain blog.domain.com without having to move the website.

RewriteCond %{HTTP_HOST} ^dominio.com [NC] RewriteRule ^(.*)$ http://www.dominio.com$1 [L,R=301] RedirectMatch 301 ^/blog/(.*)$ http://blog.dominio.com/$1

If in your .htaccess file you did not have declared RewriteEngine On, etc., then the complete code to include, at the beginning of the .htaccess file will be:

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^dominio.com [NC] RewriteRule ^(.*)$ http://www.dominio.com$1 [L,R=301] RedirectMatch 301 ^/blog/(.*)$ http://blog.dominio.com/$1

Flags:

On the third line, the flag [NC] (no-case), makes comparisons case insensitive.

Flag [L] (last) within a list of conditions, these will not be read if they are below this flag. In this case it would be the last command of this conditional rule.

Flag [R] (redirect) asks the browser to perform the redirect that should appear with the full URL.

The indicator [L,R=301] indicates that a 301 redirect should be performed permanent.

If the change was temporary you should use the indicator [L,R=302].

If you want to see the complete list of flags (in English) check RewriteRule Flags.

With this simple code in the .htaccess file you can convert an installation that you had in a folder like http://www.yourdomain.com/blog into a subdomain http://blog.yourdomain.com easier to remember and better for purposes SEO and positioning.

301 redirects

It is important that you redirect the contents of http://www.yourdomain.com/blog to http://blog.yourdomain.com if you want them to be indexed from the subdomain. If you don’t you could be serving duplicate content (same content from two different URLs).

I will tell you about it in the following video to make it easier for you to understand it.

Do not forget, after applying this change in .htaccess and verifying that your website loads normally from the subdomain, check during the following days in Google Search Console, in section Tracking, Tracking Errors that everything is correct and 404 errors or others related to the change of URI.

Member of the Websites Are Us technical team.
Coordinator of content on the Blog and YouTube.
Technical support in CyberProtector. Teacher at Websites Are Us Learning.

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