Skip to content

Instantly share code, notes, and snippets.

@allardhoeve
Created August 7, 2014 16:56
Show Gist options
  • Save allardhoeve/8b5ff5ee628033ca5885 to your computer and use it in GitHub Desktop.
Save allardhoeve/8b5ff5ee628033ca5885 to your computer and use it in GitHub Desktop.
package Byte:::Apache2::RewriteURI;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(DECLINED);
sub handler {
my $r = shift;
my $uri = $r->uri;
my ($domain) = $uri =~ m!/protected/([^/]+\.[^/]+)/!/protected/domein/!; # replace domain name by `domein` to be compat.
if ($domain) {
$r->pnotes("BYTE_URL_DOMAIN", $domain); # save the matched domain for use in Byte::AuthCookieHandler2::custom_errors
$r->uri($uri);
}
return Apache2::Const::DECLINED; # make sure other handlers (mod_rewrite) get their turn
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment