Added 301 Redirects using `RedirectMatch`

This commit is contained in:
Heiswayi Nrird 2015-08-21 10:03:25 +08:00
parent 3dd42de1a4
commit a7f13f7b44
1 changed files with 15 additions and 0 deletions

View File

@ -20,6 +20,7 @@ What we are doing here is mostly collecting useful snippets from all over the in
- [Remove Trailing Slash](#remove-trailing-slash)
- [Remove Trailing Slash from Arbitrary Paths](#remove-trailing-slash-from-arbitrary-paths)
- [Redirect a Single Page](#redirect-a-single-page)
- [Redirect using RedirectMatch](#redirect-using-redirectmatch)
- [Alias a Single Directory](#alias-a-single-directory)
- [Alias Paths to Script](#alias-paths-to-script)
- [Redirect an Entire Site](#redirect-an-entire-site)
@ -137,6 +138,20 @@ Redirect 301 /oldpage2.html http://www.example.com/folder/
```
[Source](http://css-tricks.com/snippets/htaccess/301-redirects/)
### Redirect using RedirectMatch
``` apacheconf
RedirectMatch 301 /subdirectory(.*) http://www.newsite.com/newfolder/$1
RedirectMatch 301 ^/(.*).htm$ /$1.html
RedirectMatch 301 ^/200([0-9])/([^01])(.*)$ /$2$3
RedirectMatch 301 ^/category/(.*)$ /$1
RedirectMatch 301 ^/(.*)/htaccesselite-ultimate-htaccess-article.html(.*) /htaccess/htaccess.html
RedirectMatch 301 ^/(.*).html/1/(.*) /$1.html$2
RedirectMatch 301 ^/manual/(.*)$ http://www.php.net/manual/$1
RedirectMatch 301 ^/dreamweaver/(.*)$ /tools/$1
RedirectMatch 301 ^/z/(.*)$ http://static.askapache.com/$1
```
[Source](http://www.askapache.com/htaccess/301-redirect-with-mod_rewrite-or-redirectmatch.html#301_Redirects_RedirectMatch)
### Alias a Single Directory
``` apacheconf
RewriteEngine On