My dhandler catches unknown requests. So /this-isnt-a-page.html ends up in the dhandler. The dhandler redirects to page-not-found-error.html
The redirect sends the bad page name as a parameter.
For a bad directory, /this-directory-does-not-exist Apache itself redirects:if (! ($r->uri =~ / special patterns go here /)) { $m->redirect('/page-not-found-error.html?p=' .uri_escape($r->u +ri)); }
And page-not-found-error.html ends in .html so it is also handled by mason, and it works in both cases (mason dhandler redirect or apache 404 redirect):ErrorDocument 404 /page-not-found-error.html
% my $page = uri_unescape($p) || $ENV{REDIRECT_URL}; You were looking for <% $page %> and the server can't find it.
All this works.
In page-not-found-error.html there is a hash that remaps old paths to new paths -- that is, doing aliasing via Mason rather than in apache.conf:
This works.if ($new) { # from http://www.masonhq.com/?FAQ:HTTPAndHTML $m->clear_buffer; $r->method('GET'); $r->headers_in->unset('Content-length'); $r->content_type('text/html'); $r->header_out('Location' => $new); $m->abort(301); }
I can set up a hash entry saying /login/advanced/game.html redirects to /login/agame.html and it works.
What doesn't work is when there's no file name: /this-directory-does-not-exist
While I can determine where to send it correctly, /the-right-place/index.html Apache throws an error like this
Complicated question, but why won't apache take a request for /login/advanced which then remaps to /login/advanced/index.html and is dispatchd usingNot Found The requested URL /login/advanced was not found on this server. Additionally, a 301 Moved Permanently error was encountered while tryi +ng to use an ErrorDocument to handle the request.
and do it? Why is apache bitching about$m->clear_buffer; $r->method('GET'); $r->headers_in->unset('Content-length'); $r->content_type('text/html'); $r->header_out('Location' => $new); $m->abort(301);
Help!The requested URL /login/advanced was not found on this server. Additionally, a 301 Moved Permanently error was encountered while tryi +ng to use an ErrorDocument to handle the request.
In reply to mason, dhandlers, page not found, and redirects by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |