On Wed, Aug 10, 2011 at 03:29:59PM -0400, Dave Reisner wrote:
On Wed, Aug 10, 2011 at 04:27:57PM +0200, Lukas Fleischer wrote:
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- Forgot to consider package names with length 1 here. We could probably also merge both RewriteRules. The resulting rule might be quite confusing, though.
UPGRADING | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/UPGRADING b/UPGRADING index 331870e..fd10707 100644 --- a/UPGRADING +++ b/UPGRADING @@ -22,6 +22,18 @@ ALTER TABLE PackageDepends ADD INDEX (DepName); 6. Run the upload directory transform script ("scripts/uploadbuckets.sh") and rotate the converted directory structure into place.
+7. If you want to provide backward compatible package URLs, enable mod_rewrite +and add the following to your Apache configuration (inside the "VirtualHost" +container or optionally create a ".htaccess" file in the upload directory): + +---- +RewriteEngine on +RewriteRule /packages/([^/])(/[^/]*)?$ /packages/$1/$1$2 +RewriteRule /packages/([^/]{2})([^/]*(/[^/]*)?)$ /packages/$1/$1$2
This can be written as a single rule, courtesy of DJ Mills:
RewriteRule ^/packages/([^/]{1,2})(/\1)? /packages/$1/$1
mod_rewrite doesn't work like sed(1). It always replaces the whole URL, not just the part matched by the search pattern. Anyway, good idea to take advantage of greediness. How about this one: RewriteRule ^/packages/([^/]{1,2})([^/]*(/[^/]*)?)$ /packages/$1/$1$2 Well, this will kinda fail when requesting "/packages/fo/foo" as it will try to rewrite that. Given that this rewrite rule is used to provide backward compatibility for broken AUR helpers only, I would say that this is ok, though. Maybe we should even ignore everything but PKGBUILDs and source packages: RewriteRule ^/packages/([^/]{1,2})([^/]*/(PKGBUILD|.*\.tar\.gz))$ /packages/$1/$1$2 Opinions?