How do I redirect my site using a .htaccess file? in simple way

This document will explain how to create a .htaccess file to redirect your site or site content. This will not redirect any emails for your domains.

As a configuration file, .htaccess is very powerful. Even the slightest syntax error (like a missing space) can result in your content not displaying correctly or at all.

Since .htaccess is a hidden system file, please make sure your FTP client is configured to show hidden files. This is usually an option in the program’s preferences/options.

Instructions

1. Create an empty text file using a text editor such as notepad, and save it as htaccess.txt.

NOTE:

The reason you should save the file as htaccess.txt is because many operating systems and FTP applications are unable to read or view .htaccess files by default. Once uploaded to the server you can rename the file to .htaccess.

2. Edit the contents of the file. Check the following examples:

301 (Permanent) Redirect: Point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the “mt-example.com” domain:

# This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/

302 (Temporary) Redirect: Point an entire site to a different temporary URL. This is useful for SEO purposes when you have a temporary landing page and plan to switch back to your main landing page at a later date:

# This allows you to redirect your entire website to any other domain
Redirect 302 / http://mt-example.com/

Redirect index.html to a specific subfolder:

# This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/

Redirect an old file to a new file path:

# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html

Redirect to a specific index page:

# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html

3. Upload this file and re-name it to .htaccess.

NOTE:

7 comments

  1. I’m impressed, I have to admit. Seldom do
    I encounter a blog that’s both equally educative and amusing, and without
    a doubt, you have hit the nail on the head.
    The issue is something which too few folks are speaking intelligently about.
    Now i’m very happy that I stumbled across this
    during my search for something relating to this.

  2. I all the time used to read piece of writing in news papers but now as
    I am a user of net so from now I am using net for articles
    or reviews, thanks to web.

  3. Thanks on your marvelous posting! I certainly enjoyed reading it, you will be a great author.I will make certain to bookmark your blog and will often come back later on. I
    want to encourage that you continue your great job, have a nice evening!

  4. Great beat ! I wish to apprentice while you amend your site, how could i subscribe
    for a weblog website? The account aided me a appropriate
    deal. I have been tiny bit familiar of this your broadcast provided bright transparent concept

Leave a Reply

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