1. Knowledge Base
  2. >
  3. Results
  4. >
  5. Article

Direct editing the .htaccess file (advanced users only)

.htaccess Editor

Refers to direct editing your .htaccess file, as opposed to using the .htaccess Editor provided by iPage.

Important Note on .htaccess Support: Incorrect changes to your .htaccess file can cause serious problems with your site. iPage does not provide support for any custom code or custom scripts, including custom .htaccess and .htpasswd files. You may upload and utilize these files, but we do not provide assistance with editing or troubleshooting them.

DIY: You can also create the file yourself using your preferred text editor, such as NotePad. When you have completed your file, upload it in ASCII mode via FTP to the applicable directory. The instructions below contain code examples that you can follow.

We do support the use of our .htaccess Editor and recommend using its tools over directly editing the file.

 

Standard default pages and default display order

View the Default Pages List for an ordered list of the filenames that our servers attempt to display as the default/home page for a directory. The filenames are case sensitive.


The acceptable home page filenames are listed in order of priority served by our platform. For example, if you had both index.htm and default.htm in your root directory, our platform would serve index.htm as your site's home page.

 

Enable Hotlink Protection

The Hotlink Protection tool enables hotlink protection without making you code. However, you can create and edit .htaccess files using the Direct Editor tool within our .htaccess Editor, as outlined below. The .htaccess Rewrite command will instruct the server to reject file requests from outside of your domain, which makes it impossible for other sites to load your images and other files from your site onto theirs.
  1. Log into the .htaccess Editor, and then click Direct Editor.
  2. Select the directory to which you want to add hotlink protection. The page redisplays to show the contents of the .htaccess file for that directory.
  3. In the Edit Your .htaccess File field, enter the following commands each own their own line, replacing example.com with your domain name:
     
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://www.example.com
    RewriteCond %{HTTP_REFERER} !^http://example.com
    RewriteRule <^/>+.(gif|jpg)$ -
 
  1. To protect more than .gif and .jpg files, add the extensions to protect to the list in the RewriteRule line, separating each with the pipe symbol ( | ):
RewriteRule <^/>+.(gif|jpg|jpeg|mpg|mp3)$ -
  1. To add other domains pointing to your main site, insert them below the primary domain and above the RewriteRule line:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com
RewriteCond %{HTTP_REFERER} !^http://yoursite.com
RewriteCond %{HTTP_REFERER} !^http://www.yoursite2.com 
RewriteCond %{HTTP_REFERER} !^http://yoursite2.com
RewriteRule <^/>+.(gif|jpg)$ -
  1. Click Save to save your changes. Otherwise, click Reset to return to the file's previous settings.


Hotlink Protection on Subdomains: To apply hotlink protection for sites on subdomains (http://subdomain.example.com), create an .htaccess file for each subdomain like the following example:

RewriteCond %{HTTP_REFERER} !^http://subdomain.yoursite.com/
RewriteRule <^/>+.(gif|jpg)$ -

To protect your main site and subdomains, add the main site to the subdomain code as follows:

RewriteCond %{HTTP_REFERER} !^http://subdomain.example.com/
RewriteCond %{HTTP_REFERER} !^http://www.example.com
RewriteCond %{HTTP_REFERER} !^http://yoursite.com
RewriteRule <^/>+.(gif|jpg)$ -

Replacement Images
If you want to return a 'Stop stealing my images and bandwidth!' graphic in place of the hotlinked images, change this line:

RewriteRule <^/>+.(gif|jpg)$ -
to these lines, replacing http://www.example.com/stopleeching.jpg with the URL to the image you want to use:
RewriteCond %{REQUEST_URI} !^/restricted_image.jpg
RewriteRule +.(gif|jpg)$ http://www.example.com/stopleeching.jpg
Tip: You should make the 'stop leeching' image as small as possible, so that you don't defeat the purpose of saving bandwidth by blocking image use.


Set custom error pages

You can substitute pages that you designate for the standard server error pages that display when the Web server returns unsuccessful response/status codes. Custom error pages are set in a .htaccess file using the ErrorDocument command. We recommend using the Custom Error Pages tool which enables you to set custom pages without having to code, however, if you still wish to direct edit your .htaccess file, the instructions are below.
  1. Log into the .htaccess Editor, and then click Direct Editor.
  2. Select the directory to which you want to add custom error pages. The page redisplays to show the contents of the .htaccess file for that directory.
  3. In the Edit Your .htaccess File field, enter the following command on a new line, specifying the error code and file you want to use:
    ErrorDocument ### /errorpage.html

    ### represents the server error code.
    /errorpage.html represents the URL or path to your custom error page file.

    Common errors include:
    • 403 (Forbidden)
    • 404 (Not Found)
    • 500 (Internal Server Error)
  4. For each error that you want to add, enter a separate line in the .htaccess file.
    Example:
    ErrorDocument 403 /errorpage.html
    ErrorDocument 404 /errorpage.html
    ErrorDocument 500 /errorpage.html

     
  5. Click Save to save your changes. Otherwise, click Reset to return to the file's previous settings.
 

Set custom default index pages

You can change the home page for a directory from the standard default filenames to a file that you specify using the DirectoryIndex command in your .htaccess file. You can also include a prioritized list of default pages. If the first filename listed does not exist, the server will look for the next one, and so on.

We recommend using the the Default Pages tool, which enables you to set custom index pages without having to code, however, if you still wish to direct edit your .htaccess file, the instructions are below.

  1. Log into the .htaccess Editor, and then click Direct Editor.
  2. Select the directory to which you want to specify default pages. The page redisplays to show the contents of the .htaccess file for that directory.
  3. In the Edit Your .htaccess File field, enter the following command on a line, replacing filename.html with the file you want to use:
    DirectoryIndex filename.html
  4. To specify alternative files, add them separated by a space.
    DirectoryIndex filename.html secondfile.html thirdfile.html
  5. Click Save to save your changes. Otherwise, click Reset to start over.


Block access from certain IP addresses'

You can block users from specific IP addresses or a range of IP addresses from accessing your site using the deny from command in your .htaccess file.

b recommend using the Block IP Addresses tool, which enables you to block users without having to code, however, if you still wish to direct edit your .htaccess file, the instructions are below.

  1. Log into the .htaccess Editor, and then click Direct Editor.
  2. Select the directory to which you want to block access. The page redisplays to show the contents of the .htaccess file for that directory.
  3. In the Edit Your .htaccess File field, enter the following command on its own line:
    order allow,deny
  4. Add deny from lines for each IP address or range you want to block.
    Specific IP Address
    deny from ###.###.###.###

    IP Range
    deny from ###.###.###

    Example: To ban everyone in the range 123.123.45.0 to 123.123.45.255, enter 123.123.45
  5. Enter the following command on its own line at the end.
    allow from all

    Complete Example: The following example includes one IP address and one IP range.
    order allow,deny
    deny from 123.123.45.67
    deny from 111.222.34
    allow from all
  6. Click Save to save your changes. Otherwise, click Reset to start over.
 

Redirect URLs

You can redirect requests for a specific file or directory to a new destination using the Redirect command in your .htaccess file.

We recommend using the URL Redirect tool, which enables you to redirect URLs without having to code, however, if you still wish to direct edit your .htaccess file, the instructions are below.

  1. Log into the .htaccess Editor, and then click Direct Editor.
  2. Select the directory in which you want to redirect URLs. The page redisplays to show the contents of the .htaccess file for that directory.
  3. In the Edit Your .htaccess File field, enter the following command on a new line, replacing the old and new examples, which are separated by a space:
    Redirect /olddir/oldfile.html http://yoursite.com/newdir/newfile.html

    Old: Enter the location of the file or directory that you want redirected relative to the root of your site: /olddir/oldfile.html = http://yoursite.com/olddir/oldfile.html.
    New: Enter the full URL of the location where you want requests for the old file/directory to be sent.
    If you have only renamed a directory, you can use just the directory name:
    Redirect /olddir/ http://yoursite.com/newdir
  4. Add a line for each file or directory you need to redirect.
  5. Click Save to save your changes. Otherwise, click Reset to start over.
 

Add MIME types

You can add or override system MIME types using the AddType directive in your .htaccess file.

We recommend using the MIME Types tool, which enables you to add MIME types without having to code, however, if you still wish to direct edit your .htaccess file, the instructions are below.

  1. Log into the .htaccess Editor, and then click Direct Editor.
  2. Select the directory to which you want to add MIME types. The page redisplays to show the contents of the .htaccess file for that directory.
  3. In the Edit Your .htaccess File field, enter a new line for each MIME type you want to add, using the following syntax:
    AddType MIME-type extension (extension) . . .

    MIME-type is the MIME type to use for filenames containing extension. Indicate multiple extensions by separating them with a space.
    Example:
    AddType application/x-shockwave-flash swf
  4. Click Save to save your changes. Otherwise, click Reset to start over.
 

For uploads of .htaccess and .htpasswd files

We do allow uploads of .htaccess and .htpasswd files, but apply the following restrictions:
  • For security purposes, we do not allow any of the Options features of the .htaccess AllowOverride directive on our servers. Including these in your .htaccess file will cause Internal Server errors. Refer to Apache's AllowOverride directive documentation for details.
  • We do not provide technical support to edit or troubleshoot custom code or custom scripts, including custom .htaccess and .htpasswd files.
yieldmanager

Thanks for visiting! Since you landed on this page of our website, we wanted to let you know you visited one of our paid endorsers while researching your purchase. close