Redirect individual website address to another one

To redirect individual files, like anvar.in/about.html to about-me.html you can use a 301 redirect like this:

Redirect 301 /about.html /about-me.html

To redirect one specific file to another domain such as anvar.in/oldurl.htm to anvar.in/newurl.htm:

Redirect 301 /oldurl.htm http://anvar.in/newurl.htm

Redirect an old domain to a new domain
If you had an old domain name such as anvar.com, and now you decided you actually want to use new domain anvar.in for the website. You could setup a 301 redirect for the entire domain, so that old links to anvar.com carry over.
Code in the anvar.com domain’s .htaccess file:

RewriteEngine on
 RewriteCond %{HTTP_HOST} ^xyz.com [NC,OR]
 RewriteCond %{HTTP_HOST} ^www.anvar.com [NC]
 RewriteRule ^(.*)$ http://anvar.in/$1 [L,R=301,NC]

Force to use www. in domain

A search engine like Google,yahoo,bing would see anvar.in and www.anvar.in as essentially two separate websites. They recommend you pick one version

Code in the anvar.in domain’s .htaccess file:

RewriteEngine on
 RewriteCond %{HTTP_HOST} ^anvar.in [NC]
 RewriteRule ^(.*)$ http://www.anvar.in/$1 [L,R=301,NC]

4 thoughts on “How to redirect website to another url via .htaccess

  1. Wonderful goods from you, man. I have understand your stuff previous
    to and you are just too fantastic. I really like what you’ve acquired here,
    certainly like what you’re saying and the way in which you
    say it. You make it enjoyable and you still take care of
    to keep it sensible. I cant wait to read much more from you.
    This is really a tremendous site.

Leave a Reply

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

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