no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | htaccess [2015/06/01 22:45] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== htaccess ====== | ||
+ | * [[Apache]] | ||
+ | |||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | |||
+ | ==== Redirects ==== | ||
+ | |||
+ | ^ Status ^ Definition ^ | ||
+ | | 301 | Moved permanently | | ||
+ | | 307 | Temporary redirect | | ||
+ | |||
+ | == Redirect a single file == | ||
+ | |||
+ | < | ||
+ | Redirect 301 / | ||
+ | </ | ||
+ | |||
+ | == Redirect entire site to new domain == | ||
+ | |||
+ | < | ||
+ | Redirect 301 / http:// | ||
+ | </ | ||
+ | |||
+ | == Redirect site to HTTPS == | ||
+ | |||
+ | < | ||
+ | RewriteCond %{HTTPS} off | ||
+ | RewriteRule (.*) https:// | ||
+ | </ | ||
+ | |||
+ | == Redirect all non-domain names to the domain == | ||
+ | |||
+ | < | ||
+ | RewriteEngine On | ||
+ | RewriteCond %{HTTP_HOST} !^www.domain.com | ||
+ | RewriteRule (.*) http:// | ||
+ | </ | ||
+ | |||
+ | Same with not specifying a specific domain -- works for virtual hosts: | ||
+ | |||
+ | < | ||
+ | RewriteCond %{HTTP_HOST} !^www\. [NC] | ||
+ | RewriteRule ^(.*)$ http:// | ||
+ | </ | ||
+ | |||
+ | == Redirect non-www prefix for a domain to www == | ||
+ | |||
+ | < | ||
+ | RewriteCond %{HTTP_HOST} ^example.com | ||
+ | RewriteRule (.*) http:// | ||
+ | </ | ||
+ | |||
+ | == Rewrite if REQUEST_URI matches string == | ||
+ | |||
+ | You can use Perl regular expression syntax with RewriteCond | ||
+ | |||
+ | < | ||
+ | RewriteCond %{REQUEST_URI} ^/ | ||
+ | RewriteRule ^(.*)$ https:// | ||
+ | |||
+ | ==== Access ==== | ||
+ | |||
+ | == Allow access from subnet only == | ||
+ | |||
+ | < | ||
+ | Order Deny,Allow | ||
+ | Deny from all | ||
+ | Allow from 192.168.1.0/ | ||
+ | </ | ||
+ | |||
+ | == Require either user authentication or subnet access == | ||
+ | |||
+ | The '' | ||
+ | |||
+ | < | ||
+ | < | ||
+ | Order allow,deny | ||
+ | Allow from 192.168.12.0/ | ||
+ | AuthType Basic | ||
+ | AuthName " | ||
+ | AuthUserFile / | ||
+ | Require valid-user | ||
+ | Satisfy any | ||
+ | </ | ||
+ | </ |