2
0
mirror of https://github.com/phanan/htaccess.git synced 2018-11-08 13:39:40 +01:00

Merge branch 'master' of https://github.com/alexweissman/htaccess into alexweissman-master

This commit is contained in:
An Phan 2015-02-10 23:04:56 +08:00
commit 16d6f760bb

View File

@ -17,7 +17,9 @@ What I'm doing here is mostly collecting useful snippets from all over the inter
- [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy) - [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy)
- [Force Trailing Slash](#force-trailing-slash) - [Force Trailing Slash](#force-trailing-slash)
- [Redirect a Single Page](#redirect-a-single-page) - [Redirect a Single Page](#redirect-a-single-page)
- [Alias a Single Directory](#alias-a-single-directory)
- [Redirect an Entire Site](#redirect-an-entire-site) - [Redirect an Entire Site](#redirect-an-entire-site)
- [Alias Clean URLs](#alias-clean-urls)
- [Security](#security) - [Security](#security)
- [Deny All Access](#deny-all-access) - [Deny All Access](#deny-all-access)
- [Deny All Access Except Yours](#deny-all-access-except-yours) - [Deny All Access Except Yours](#deny-all-access-except-yours)
@ -94,12 +96,28 @@ Redirect 301 /oldpage2.html http://www.yoursite.com/folder/
``` ```
[Source](http://css-tricks.com/snippets/htaccess/301-redirects/) [Source](http://css-tricks.com/snippets/htaccess/301-redirects/)
### Alias a Single Directory
``` apacheconf
RewriteEngine On
RewriteRule ^source-directory/(.*) target-directory/$1
```
### Redirect an Entire Site ### Redirect an Entire Site
``` apacheconf ``` apacheconf
Redirect 301 / http://newsite.com/ Redirect 301 / http://newsite.com/
``` ```
This way does it with links intact. That is `www.oldsite.com/some/crazy/link.html` will become `www.newsite.com/some/crazy/link.html`. This is extremely helpful when you are just "moving" a site to a new domain. [Source](http://css-tricks.com/snippets/htaccess/301-redirects/) This way does it with links intact. That is `www.oldsite.com/some/crazy/link.html` will become `www.newsite.com/some/crazy/link.html`. This is extremely helpful when you are just "moving" a site to a new domain. [Source](http://css-tricks.com/snippets/htaccess/301-redirects/)
### Alias "Clean" URLs
``` apacheconf
# This snippet lets you use "clean URLs", without a PHP extension.
# Example: "example.com/users" => "example.com/users.php"
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]
```
[Source](http://www.abeautifulsite.net/access-pages-without-the-php-extension-using-htaccess/)
## Security ## Security
### Deny All Access ### Deny All Access
``` apacheconf ``` apacheconf