Hi, folks,

I am hoping to redirect URLs like:

   http://example.com/?question

to

  http://example.com/doc/question.mhtml

###########################
with dhandler's mechanism and currently in /dhandler, I set:

<%init>
my %redirects = (
        '/?question'       => '/doc/question.mhtml'
);

# or combine $r->uri and $r->args to get $req
my $req = $ENV{REQUEST_URI};

$r->content_type('text/html');
if (exists $redirects{ $req }) {
    $m->redirect($redirects{ $req });
}

$m->clear_and_abort(404);
</%init>
########################

If I don't do any more configuration with apache2, all links like
http://example.com/?question always go directly to my homepage
/index.mhtml no matter what query string I used after the '/?'. If I
do the following configuration under Apache2.

    RewriteCond %{QUERY_STRING}           !^$
    RewriteRule ^/$                      /nonexist.mhtml [L]

========
then "http://example.com/?question"; will bring me to "/dhandler" but
it displays plain text of dhandler instead of html even if I set
$r->content_type. I guess this might becouse the 'redirection' occurs
before the content generation phase thus the Mason handler does not
get a chance to handle this. I have the following configuration in
Apache:

<LocationMatch "\.mhtml$|^/\?[^/]+$">
    SetHandler perl-script
    PerlResponseHandler +MyApp::Mason
</LocationMatch>

<LocationMatch "(\.mas|autohandler|dhandler)$">
    SetHandler perl-script
    PerlInitHandler Apache2::Const::NOT_FOUND
 </LocationMatch>

Can someone shed some light to me with this problem? I know many
websites are using this kind of redirection(mason home and perl
design-pattern site), there must be some easier/good ways to handle
this. I am using Apache/2.0.55, mod_perl/2.0.2, Perl/v5.8.7 and
Mason/1.35..

Thank you very much for your time..

Regards,
Xicheng

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to