-
-
Save xikaos/4129b68e64c698975a1c to your computer and use it in GitHub Desktop.
Just some trivial tasks to do with .htaccess
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment