On 6/24/07, Xicheng Jia <[EMAIL PROTECTED]> wrote: > 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:
$r->content_type() seems working correctly, not sure what was wrong with my previous tests though:<. Now I can filter URLs like http://example.com/?question from http://example.com/ with my apache rewrite rule. But /dhandler seems not working at this point, the page http://example.com/?question directly goes to the http://example.com/lib/error.mhtml I am guessing that the request does not get a chance to touch /dhandler and use Mason..since I set the following in my apache: ErrorDocument 404 /lib/error.mhtml If I move my previous redirection code from /dhandler to /lib/error.mhtml =============== my %redirects = ( '/?ck' => '/lib/check.mhtml', ........ ); my $req = $ENV{REQUEST_URI}; # If it's moved, send them there immediately. if (exists $redirects{ $req }) { $r->headers_out->set( Location => $redirects{ $req } ); $r->content_type( 'text/html' ); $r->status(301); } ================ this worked but I am hoping to find a solution by /dhandler.. Any suggestions? thanks .. 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

