From 72cd2ccdec0622d92b9e2e57aec56032b2962de2 Mon Sep 17 00:00:00 2001 From: Alex Weissman Date: Mon, 9 Feb 2015 11:54:03 -0500 Subject: [PATCH 1/5] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c4bf5f..3a99feb 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ A collection of useful .htaccess snippets, all in one place. I decided to create - [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy) - [Force Trailing Slash](#force-trailing-slash) - [Redirect a Single Page](#redirect-a-single-page) + - [Redirect a Single Directory](#redirect-a-single-directory) - [Redirect an Entire Site](#redirect-an-entire-site) - [Security](#security) - [Deny All Access](#deny-all-access) @@ -91,6 +92,11 @@ Redirect 301 /oldpage2.html http://www.yoursite.com/folder/ ``` [Source](http://css-tricks.com/snippets/htaccess/301-redirects/) +### Redirect a Single Directory +``` apacheconf +#RewriteRule ^source-directory/(.*) target-directory/$1 +``` + ### Redirect an Entire Site ``` apacheconf Redirect 301 / http://newsite.com/ @@ -354,4 +360,4 @@ AddHandler application/x-httpd-php55 .php # Alternatively, you can use AddType AddType application/x-httpd-php55 .php -``` \ No newline at end of file +``` From 8dcc966a2f692e71e2d1d925d9ffccf60c41cecc Mon Sep 17 00:00:00 2001 From: Alex Weissman Date: Mon, 9 Feb 2015 11:54:30 -0500 Subject: [PATCH 2/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a99feb..c7f9ebd 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Redirect 301 /oldpage2.html http://www.yoursite.com/folder/ ### Redirect a Single Directory ``` apacheconf -#RewriteRule ^source-directory/(.*) target-directory/$1 +RewriteRule ^source-directory/(.*) target-directory/$1 ``` ### Redirect an Entire Site From 0fc118e01b1872adcad90b629ff22d4ea296218a Mon Sep 17 00:00:00 2001 From: Alex Weissman Date: Mon, 9 Feb 2015 12:06:08 -0500 Subject: [PATCH 3/5] Update README.md --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c7f9ebd..bda01ab 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,9 @@ A collection of useful .htaccess snippets, all in one place. I decided to create - [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy) - [Force Trailing Slash](#force-trailing-slash) - [Redirect a Single Page](#redirect-a-single-page) - - [Redirect a Single Directory](#redirect-a-single-directory) + - [Redirect a Single Directory](#alias-a-single-directory) - [Redirect an Entire Site](#redirect-an-entire-site) + - [Clean URLs](#alias-clean-urls) - [Security](#security) - [Deny All Access](#deny-all-access) - [Deny All Access Except Yours](#deny-all-access-except-yours) @@ -92,8 +93,9 @@ Redirect 301 /oldpage2.html http://www.yoursite.com/folder/ ``` [Source](http://css-tricks.com/snippets/htaccess/301-redirects/) -### Redirect a Single Directory +### Alias a Single Directory ``` apacheconf +RewriteEngine On RewriteRule ^source-directory/(.*) target-directory/$1 ``` @@ -103,6 +105,16 @@ 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/) +### 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 ### Deny All Access ``` apacheconf From b6fb060a8d85efe355df86c52ec949be7edd76d8 Mon Sep 17 00:00:00 2001 From: Alex Weissman Date: Mon, 9 Feb 2015 12:07:28 -0500 Subject: [PATCH 4/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bda01ab..9da2c05 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ A collection of useful .htaccess snippets, all in one place. I decided to create - [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy) - [Force Trailing Slash](#force-trailing-slash) - [Redirect a Single Page](#redirect-a-single-page) - - [Redirect a Single Directory](#alias-a-single-directory) + - [Alias a Single Directory](#alias-a-single-directory) - [Redirect an Entire Site](#redirect-an-entire-site) - - [Clean URLs](#alias-clean-urls) + - [Alias Clean URLs](#alias-clean-urls) - [Security](#security) - [Deny All Access](#deny-all-access) - [Deny All Access Except Yours](#deny-all-access-except-yours) From 08aa0085406cd84a7310002ccc2c09e0325dab1a Mon Sep 17 00:00:00 2001 From: An Phan Date: Tue, 10 Feb 2015 23:10:24 +0800 Subject: [PATCH 5/5] Rewording @alexweissman fork --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 99d5f9c..5e315a9 100644 --- a/README.md +++ b/README.md @@ -109,9 +109,8 @@ 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/) ### Alias "Clean" URLs +This snippet lets you use "clean URLs" -- those without a PHP extension, e.g. `example.com/users` instead of `example.com/users.php`. ``` 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]