RSS

Help with .htaccess files

Fri, Jul 4, 2008

Tutorials

Please note that .htaccess files affect ALL subdirectories of the folder it is placed into.

To create a .htaccess file in windows, use notepad to create a new document, and save it as htaccess.txt. When you have uploaded it to the server, simply rename it .htaccess

Once uploaded, the .htaccess file may disappear from view, this is because it is a hidden file, and some FTP clients do not automatically show hidden files.

ErrorDocument

To make your own custom error pages, create a new document in notepad, and enter the following line:

ErrorDocument XXX /path to your/errordocument.ext

Where
XXX - is the errordocument you want to replace i.e.
401 Not authorised
403 Forbidden
404 Page not found

/path to your/errordocument – is the path to your error page relative to the httpdocs folder (ie /error/404.php)

and .ext is the extension you want the page to have, i.e.
.html
.php

Save the file as htaccess.txt, upload it to your httpdocs folder, and rename it to .htaccess

Example:
ErrorDocument 404 /error/404.php

Note:
You cannot call the directory where you store your error pages error_docs

Tips

Other useful .htaccess tips

If you’ve uploaded an .htaccess file, and you can’t see it in your FTP client, then you will need to add a filter. Somewhere in the settings, there will be an option to add a remote filter, you need to add -a which will tell your FTP client to show hidden files (on linux hosting servers, files starting with a . are hidden).

To make a directory show a list of files, rather than auto-load an index file, put the following line into an .htaccess file in the directory you want to ‘index’:

Options +Indexes


To change the default index file for a directory, put this line:

DirectoryIndex somefile.ext

Where somefile is your filename, and ext is the file extension (php, html)

Example:
DirectoryIndex home.php


To run PERL scripts outside the cgi-bin, put this line into the .htaccess file for the directory where you want to run the PERL script:

Options +ExecCGI
AddHandler cgi-script .cgi .pl


To block a certain IP from viewing a folder (or your whole site), you need to add the following lines:

Order Allow,Deny
Allow from all
Deny from IP.TO.BLOCK

Where IP.TO.BLOCK is the IP address you wish to stop accessing your site/folder



2 Comments For This Post

  1. Jemuel Says:

    i’ve followed the steps to create a .htaccess.. but somehow it’s not working.
    I want to do the following, I’ve put this inside the .htaccess

    php_value upload_max_filesize 100M
    php_value max_execution_time 800
    php_value post_max_size 100M
    php_value max_input_time 100
    php_value memory_limit 120M

    any help would be appreciated..

  2. Root Says:

    Hi Jemuel, you should read our terms of service (http://www.philhosting.net/terms-of-service.html) under System Resources->Server limits for your reference doing this.
    All of the php_value will not work on .htaacess because you overiding the system resources limits applied in all our shared hosting plans. Always remember that you are using a shared hosting services, whatever attempt overiding the system resources will affect the other clients hosted in the same server where your account is hosted.

    We don’t allow this to maintain the stability and quality of our service that benefits all clients. You can only do that if you are running your own dedicated server or VPS where you owns all your server resources.

    Always remember to READ first our TOS to avoid any account problems.

Leave a Reply