Are you a blogger? Then, don’t tell me that you are unaware of Subdomains. In simpler terms, subdomains are the subdivisions of your main website. You can have custom URLs in front of the main domain (for example blog.yourdomain.com).
Subdomains are useful for every website. As I mentioned in the previous example, you can have a blog on the subdomain. The added advantage is that you can install WordPress on that particular subdomain without affecting other subdomains or the entire website.
Sometimes, we need to Redirect all the subdomains to the root URL. So, today you are going to learn how to 301 redirect all subdomains.
Also Read: – How to Block Email Address from Commenting in WordPress
How to 301 Redirect All Subdomains
Though several types of redirect are there, the best one is 301 because it passes the link juice and SEO benefits to the target site.
You can do it in multiple ways. But the best way is manual method. As you will not be using any plugin, the site load speed remains unchanged.
Redirection is useful in many occasions. Suppose, you changed or deleted a subdomain. Still, Google shows your subdomain in SERPs. As a result, people come to your blog and get a 404 error.
Inevitably, it will create a bad feedback in the visitors. Adding salt to the injury, your main site’s search engine visibility may also be badly affected because search engines don’t like 404 error pages.
In this tutorial, I am going to two ways through which you can know how to 301 redirect all subdomains.
How to 301 Redirect All Subdomains without any Plugin
We are not using any plugin here. Then, how can you set up redirection in a correct manner without ending up on not found pages. Follow the steps given below.
Go to your site’s cpanel and get access to your site files via an online file manager. You can also try out FTP software like FileZilla. Go to the www section of your blog. There, you can see a .htaccess file. We need to edit this in order to set the redirection.
Add the following code into .htaccess file and click save. That’s all.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Change yourdomain.com into the exact domain.
Also Read: – How to Allow WordPress Contributors to Upload Media
How to 301 Redirect All Subdomains with Plugin
A number of plugins are available on WordPress repository that can serve the purpose very well. Just install one of those plugins and act accordingly.
Here are some plugins.
Simple 301 Redirects
SEO Redirect 301s
Redirects
Redirection
I hope everything is clear now. Have a nice day
The post How to 301 Redirect All Subdomains? appeared first on Crack Aloud.
This post first appeared on Crack Aloud - Useful Tips, Tricks And Tutorials, please read the originial post: here