pavement

.htaccess

From FreeBSDwiki
Revision as of 17:00, 18 April 2007 by Jimbo (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can place a .htaccess file in a directory serviced by apache to override server default behaviors without needing to alter httpd.conf or even to restart Apache - assuming, of course, that the directory in question has been allowed override privileges for the things you want to do!

For example, assuming mod_rewrite is installed and available in Apache, you can do the following in the .htaccess file in the root of a site to redirect an insecure http request to the same site via secure https:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Or if you want to block off a pesky spammer-ridden IP block:

# CHINANET telcom - 2006-03-02
deny from 212.0.0.0/8
deny from 216.0.0.0/8
deny from 218.0.0.0/8
deny from 221.0.0.0/8
deny from 61.144.0.0/14

Note that comments - prefaced by # signs - ARE allowed in .htaccess files. Use this to your advantage!

Personal tools