.htaccess can be used for almost anything.
You can use it to tell PHP to turn safe mode on or off, change limits for certain scripts, and other neat stuff.
Code:
#
# Apache/PHP/site settings:
#
# Protect files and directories from prying eyes:
<Files ~ "(\.(conf|inc|module|pl|sh|sql|theme)|Entries|Repositories|Root|scripts|updates)$">
order deny,allow
deny from all
</Files>
# Set some options
Options Indexes FollowSymLinks
# Customized server error messages:
ErrorDocument 400 /error.php
ErrorDocument 402 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
# Overload PHP variables:
<IfModule mod_php4.c>
php_value register_globals 0
php_value track_vars 1
php_value short_open_tag 1
php_value magic_quotes_gpc 0
php_value magic_quotes_runtime 0
php_value magic_quotes_sybase 0
php_value arg_separator.output "&"
php_value session.cache_expire 200000
php_value session.gc_maxlifetime 200000
php_value session.cookie_lifetime 2000000
php_value session.auto_start 0
php_value session.save_handler files
php_value session.cache_limiter none
php_value allow_call_time_pass_reference On
# php_value session.save_path /home/personal/public_html/temp
</IfModule>
# Various rewrite rules
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite old-style URLS of the form 'node.php?id=x':
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^id=([^&]+)$
RewriteRule node.php index.php?q=node/view/%1 [L]
# Rewrite old-style URLs of the form 'module.php?mod=x':
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
RewriteRule module.php index.php?q=%1 [L]
# Rewrite URLs of the form 'index.php?q=x':
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
Is what i use on http://personal.x-istence.com/ with Drupal to allow for neat links, and so it can function properly.
Blocking certain extensions and or directories is really nice as well, this way people do not get to go in and take a look at em.
Code:
RewriteEngine on
# Lets not allow people to hotlink images. Its not very nice of them is it?
# The sites we want to allow are the ones we list here, others are blocked.
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?x-istence.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?download.x-istence.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?personal.x-istence.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?tutorials.x-istence.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?forums.x-istence.com(/)?.*$ [NC]
# This is our rewrite rules
RewriteRule .*\.(gif|jpg|jpeg|bmp|png|wav|zip|mpg)$ - [F,NC]
My Rewrite rules to stop people from other sites hotlinking my images. Works especially effective. Better than the standard cPanel ones i might add.