How to 301 Redirect all Subdomains by using htaccess

There are some ways to redirect all sub-domains , but the very easiest way redirect by using .htaccess

Go to your file manager ,  open your .htaccess ;  if you don’t have .htaccess file into your file manager then create the file and use the following codes :

RewriteEngine On

RewriteCond %{HTTP_HOST} ^[^.]+\.(domain\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]

 

That’s it .

You May Also Like

About the Author: Bipul

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.