Redirecting to the Latest Version of a File


RedirectMatch myapp-(1|2)\.([0-9])(\.[0-9])?-(.*) /myapp-3.0-$4


The RedirectMatch directive is similar to Redirect, but allows the origin URL path to be a regular expression. This allows a great amount of flexibility. For example, imagine you are a software company distributing downloads from your website and release new versions of a particular product over time. You may find that a certain percentage of your users are still downloading older versions of your software through third-party websites that have not yet updated their links. Using RedirectMatch, users who request old versions of the file can be easily redirected to the latest version. For example, suppose the name of the latest version of your downloadable file is myapp-3.0. This example will redirect requests for http://www.example.com/myapp-2.5.1-demo.tgz to http://www.example.com/myapp-3.0-demo.tgz and requests for http://www.example.com/myapp-1.2-manual.pdf to http://www.example.com/myapp-3.0-manual.pdf.

The first three elements of the regular expression will match a major and minor number and an optional patch number. Those will be replaced by 3.0. The remaining part of the filename is captured in the final regular expression group and replaced in the destination URL.




Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net