htaccess Directives

Control Panel: WebsiteOS


htaccess Directives/Files: provide per directory instructions to the Apache web server, to override default Apache behavior or add additional functionality.

A file containing one or more configuration directives is placed in a particular document directory; the directives apply to that directory and all subdirectories thereof.

If you are creating these files in notepad, copy and paste the text you wish to use. Once the file is uploaded to the specific directory remember to rename the file to ".htaccess" .

# Allows CGI/PERL Scripts to run
AddHandler cgi-script .cgi .pl

# Allows .wma files to be streamed
AddType audio/x-ms-wma wma

# 'Stream' MP3 files from your website
AddType audio/mpeg mp3 MP3
AddType audio/playlist m3u M3U

# To force a file to be downloaded, via the Save As browser feature.
# change 'ext' to the extension you want to force download.
AddType application/octet-stream ext

# Allows the viewing of directories with fancy output without an Index file
Options All Indexes
IndexOptions FancyIndexing NameWidth=*

# Error Document Reporting
ErrorDocument 404

# Rewrite code that works on our system so that only links from your site
# are allowed to access (ext, ext1). This just gives error 403 Forbidden.
SetEnvIfnoCase Referer "^http://(www\.)?domain\.com" locally_linked
SetEnvIf Referer "^$" locally_linked

Order Allow,Deny
Allow from env=locally_linked

# Allows a new filename or file name order preference for the Index page
DirectoryIndex filename.html index.cgi default.htm index.php

# Allows you to deny (txt,ext2) extensions from being displayed in dir1|dir2
order deny,allow
deny from all

# Denies the following IP Address(es)
deny from
deny from 111.111.111.

# Redirects /dir/ to
Redirect /

# Redirects index file (source directory i.e. public)/ to
Redirect /index.ext

# Catching PHP errors:
php_flag display_errors on
php_value error_reporting 7

# Turning off Case Sensitivity:
CaseInsensitive On

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Definition: Hypertext Access (htaccess)

An htaccess file (Hypertext Access) is an ASCII file which can be created in a text editor like...