How to redirect your site using htaccess Print

  • 73

It is sometimes necessary to redirect an entire domain to another destination domain . This can be done with a redirect htaccess file placed in the root of your web folder. If the file aready exists you can just edit it , if not you will need to create it.

Open your favourite text editor and enter the following txt at the top replacing www.destinationdomain.com with your destination domain.

#This allows you to redirect your entire website to any other domain
Redirect 301 / http://destinationdomain.com/
# This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://destinationdomain.com/newdirectory/
# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://destinationdomain.com/newdirectory/newfile.html
# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html

Save this file as htaccess.txt

Using an FTP client upload this file to the root web folder of your domain you are creating the redirect for. Rename the htaccess.txt file to .htaccess (important) and make sure the files permissions are set to 644

Now visitors who go to www.sourcedomain.com will be auto redirected to www.destinationdomain.com


Was this answer helpful?

« Back