NameVirtualHost *
DocumentRoot /web/example.com/www
ServerName www.example.com
ServerAlias example.com
CustomLog /web/example.com/logs/access.log combined
ErrorLog /web/example.com/logs/error.log
# Include another conf file
Include /etc/apache/virtual-hosts/*.conf
# Hide apache version info
ServerSignature Off
ServerTokens Prod
Custom 404 Error message
ErrorDocument 404 /404.html
#Create a virtual directory (mod_alias)
Alias /common /web/common
#Perminant redirect (mod_alias)
Redirect permanent /old http://example.com/new
#Hide apache version infoCreate a cgi-bin
ScriptAlias /cgi-bin/ /web/cgi-bin/
Process .cgi scripts
AddHandler cgi-script .cgi
#Add a directory index
DirectoryIndex index.cfm index.cfm
#Turn off directory browsing
Options -Indexes
Turn on directory browsing
Options +Indexes
Create a new user for basic auth (command line)
htpasswd -c /etc/apacheusers
#Apache basic authentication
AuthName "Authentication Required"
AuthType Basic
AuthUserFile /etc/apacheusers
Require valid-user
Only allow access from a specific IP
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Only allow access from your subnet
Order Deny,Allow
Deny from all
Allow from 176.16.0.0/16
mod_rewrite
#Turn on the rewrite engine
RewriteEngine On
# Redirect /news/123 to /news.cfm?id=123
# Flags
# [NC] No case sensitive
# [OR] Allows multiple lines
# [R=#] Redirect where # is number: 404.
# [L] Terminate routine
# . Every char
# < > = Compare
# \ Escape a char
# .+ One more, more chars
# .* No chars or multiple chars
# ^ Start
# $ End
# (…) Group
# a|b .A or B
# (a|b) .A or B group
# a{5} Exact 5 times a
# a{1,5} Between 1 and 5 times a
# [a-z]* Match chars
# -d Directory
# -f File
# -l Symbolic link
RewriteRule ^/news/([0-9]+)$ /news.cfm?id=$1 [PT,L]
#Redirect www.example.com to example.com
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
#add apache user -b pass to the command line
htpasswd - b GroupToAddTo FirstNameLastName theVarySecretPass
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!