Hi All, What i am trying to do is:
* If a user goes to http://myhost/[A-Za-z]{3}[0-9]{3} (eg. http://myhost/abc123) Then i want to redirect them to "/" and set their cookie based on where they tried to go (eg. set cookie Referer=abc123) To do the above, i setup the following apache configuration: <LocationMatch "^/[A-Za-z][A-Za-z][A-Za-z][0-9][0-9][0-9]"> PerlFixupHandler MyModule::Handlers::setCookie PerlHandler MyModule::Handlers::setCookie </LocationMatch> The relevant perl code is: ------------------------------------------------------------------------ sub setCookie { my $request = instance Apache::Request(shift); if ($request->current_callback eq "PerlFixupHandler") { warn "PerlFixupHandler...\n"; return DECLINED; } warn "PerlHandler...\n"; if ($request->uri =~ m!^/([A-Za-z]{3}[0-9]{3})!) { $request->header_out("Set-Cookie", "Referer=$1"); $request->content_type('text/html'); my $server_and_port = $ENV{'HTTP_HOST'}; $request->send_http_header(); $request->print("<meta http-equiv=Refresh CONTENT=\"0; URL=http://$server_and_port/\">"); return OK; } else { return DECLINED; } } ------------------------------------------------------------------------ What happens is that if the relevant directory exists in the document root (eg. if the directory abc123 existed) then all would work, else, i get a "Not Found" error. How do i make it so that the directory does not need to exist... I have put in the above PerlFixupHandler stuff above to try to do this via returning a DECLINED or even changing the $request->filename(...) to a filename that exists on my system (eg. $request->filename("/etc/hosts")) but it does not work. Any suggestions on how to make the above work, or even how to do the above (set a cookie and redirect the user) in a much neater way would be appreciated. I am using: * Apache/1.3.27 (Unix) mod_gzip/1.3.19.2a mod_ssl/2.8.14 OpenSSL/0.9.6c DAV/1.0.3 mod_perl/1.28 thanks, simran.