How do I Redirect my site using a .htaccess file ?

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.

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 "hostitsmart- example.com" domain:

                 # This allows you to redirect your entire website to any other domain

                 Redirect 301 / http://hostitsmart-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://hostitsmart-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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Domain Can not view accounts in cPanel/WHM

There are many reason for an active account to  disappear from WHM List Accounts. Assuming the...

Explain Awstats Stats

The Awstats tool provides very useful information about the visits on your website. In this...

Generate CSR From Cpanel

To Generate a Certificate Signing Request (CSR) perform the following steps:1. Login to cPanel.2....

How can I access my website statistics

Your website's statistics are available under the Logs section in your cPanel. There you will see...

How can I check my quota and bandwidth limits/usage?

The statistics for your account's disk space and bandwidth usage are available in your cPanel,...