If you have a website and you are planning to redirect to a new one, but you also worried about search engine rankings, which rely on your old website, so don’t worry, there is a more effective or search engine friendly technique “301 redirect” that you can use Easy Steps to Redirect Your Website to a new one permanently.

What is a 301 redirect?
If you want to change the web page or a website or we can simply say that to change/move old url to new one, we used 301 redirect. It is the most effective method that permanently moves Webpage to New Location. It is such type of code status that moves your page to a new location.

So what are the necessary things that you need it for using 301 redirect?
Apache server :
It is the most used free web servers in the world. Most hosting services are using apache now a days. Just go to your hosting and check it out.
.htaccess file : .htaccess is the most powerful file that is located in your public_html folder. It contains specific directions that are interpreted and return to the browser.

How do I redirect my site using a .htaccess file?
When you need to change a web page from an old sector to a new sector, you need to divert all your web page URLs, this is when .htaccess.
The rule below can provide 301 URL blows for both the www and non-www form of ‘olddomainname.com‘ to the new sector ‘newdomainname.com‘.
So the example below is course-plotting all URLs from olddomain.com to newdomain.com
  • Just open a notepad or any other text editor to create an empty text file.
  • Here is the code that you need to write in your text file.
Redirect 301 / your website url
/ Indicates everything that will redirect permanently from old website to your new one.
  • Save this file as .htaccess to the root directory and upload on your server.
  • Check out your old website url by typing in the browser. It will instantly redirect to your new website address.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.olddomainname\.com$
RewriteRule (.*) http://www.newdomainname.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^olddomainname\.com$
RewriteRule (.*) http://www.newdomainname.com/$1 [R=301,L]
You can also implement this to a subdomain – so the example below is
Redirecting all URLs from subdomain.xyz.com to subdomain.abc.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain.xyz.com$
RewriteRule ^(.*)$ http://subdomain.abc.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.subdomainxyz.com$
RewriteRule ^(.*)$ http://subdomain.abc.com/$1 [R=301,L]
Directory or WebSite to go over HTTPS SSL with htaccess
To force how to use the protected method SSL operating the whole website over HTTPS you can make an effective modify to the .htaccess file in the document root
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.hoststud.com/$1 [R,L]
WWW to non-WWW Redirection with htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
This code will move your website or webpage in new address permanently. If you want temporary redirection so you can use below code and follow the same steps as above.
Redirect 302 / your website url
Author
bhawanisingh
Views
1,643
First release
Last update
Rating
0.00 star(s) 0 ratings
Top