Note: Applies to Linux hosting accounts only.

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

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.

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

Point an entire site to a different URL, such as domain.net redirected to domain.com:

# This allows you to redirect your entire website to any other domain
Redirect 301 / http://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
  • 1 Users Found This Useful

Was this answer helpful?

Related Articles

Redirect non-SSL to SSL in Linux (Apache)

Create a file .htaccess in the document root of your site with the following code.  If this file...

Redirect non-SSL to SSL in Windows (IIS)

The following code sample will 301-redirect http://www.domainname.com to...

Enable custom error pages on IIS 7 (Windows 2008) and newer

Custom error pages can be implemented in IIS 7 (Windows 2008) and newer by placing a web.config...

Remotely view error messages on IIS 7 (Windows 2008) and newer

When a website page encounters a coding error on a IIS 7 (Windows 2008) or newer hosting server,...

ODBC Connection String for MySQL

In an environment where the IIS worker process runs as 32-bit, use one of the following:...