xikaos
1/21/2016 - 5:48 PM

Just some trivial tasks to do with .htaccess

Just some trivial tasks to do with .htaccess

<IfModule mod_rewrite.c>

	# Redirect to another domain
	RewriteCond %{HTTP_HOST} ^example\.com$ [NC] # Here goes the regex to match the domain that will be redirected
	RewriteCond %{HTTP_HOST} ^(www\.)?example\.net$ [NC] # Create a new condition for every domain, if possible
	RewriteRule ^(.*)$ http://www.example.it/$1 [R=301,NC,L]
	
	# Force redirect to www
	RewriteEngine On
	RewriteCond %{HTTP_HOST} !^www\.
	RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

</IfModule>

# Prevent directory listing
Options -Indexes

# HTTP authentication
SetEnvIfNoCase Host example\.com$ require_auth=true # Define here the domain that should be authenticated

AuthType Basic
AuthName "Authentication message" # The message that appears to the user
AuthUserFile /home/example/site/.htpasswd # Set here the absolute path to htpasswd file

Order Deny,Allow
Deny from all
Satisfy any
Require valid-user
Allow from env=!require_auth