Last active
March 22, 2017 16:07
-
-
Save julian-klode/600237d0b61cf92b01748b25cf5921d7 to your computer and use it in GitHub Desktop.
changelog components redirector .htaccess file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Boilerplate | |
Options +Indexes | |
RewriteEngine on | |
## Sample redirect rules for every section. | |
# | |
# This file assumes that the changelogs are exposed at /changelogs/pool/COMPONENT/..., like | |
# on the Debian and Ubuntu servers, and that changelogs is a subdirectory of the document root. | |
# | |
# The first condition prevents infinite redirects (alternative: RewriteCond $1 !^main$) | |
# The second condition checks if the requested document exists in another component | |
# The redirect rule finally performs the redirect to the other commponent | |
RewriteCond "%{REQUEST_FILENAME}" !-f | |
RewriteCond "%{DOCUMENT_ROOT}/changelogs/pool/main/$2" -f | |
RewriteRule "pool/(.*?)/(.*)" "/changelogs/pool/main/$2" [R=301,L] | |
RewriteCond "%{REQUEST_FILENAME}" !-f | |
RewriteCond "%{DOCUMENT_ROOT}/changelogs/pool/restricted/$2" -f | |
RewriteRule "pool/(.*?)/(.*)" "/changelogs/pool/restricted/$2" [R=301,L] | |
RewriteCond "%{REQUEST_FILENAME}" !-f | |
RewriteCond "%{DOCUMENT_ROOT}/changelogs/pool/universe/$2" -f | |
RewriteRule "pool/(.*?)/(.*)" "/changelogs/pool/universe/$2" [R=301,L] | |
RewriteCond "%{REQUEST_FILENAME}" !-f | |
RewriteCond "%{DOCUMENT_ROOT}/changelogs/pool/multiverse/$2" -f | |
RewriteRule "pool/(.*?)/(.*)" "/changelogs/pool/multiverse/$2" [R=301,L] |
Thanks Julian. This was deployed today on changelogs.ubuntu.com!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You might want to handle
?
parameters in theRewriteRule
by adding(\?.*)?
to the source and$3
to the target, so these are preserved.Oh, it actually seems to just work, even without special handling :)