On Mon, Mar 24, 2008 at 2:20 PM, fixed <[EMAIL PROTECTED]> wrote:
> I'm having a bit of a problem configuring Apache with Mason and having the
> DirectoryIndex to work.
>
> My whole objective is to have URLs (which won't exist) such as:
>
> http://localhost/mondays
> http://localhost/tuesdays
>
> Therefore, my dhandler is:
>
> <%init>
> my $day = (split /\//, $r->uri)[-1];
> $m->comp("process_days.mpl", day => $day);
> </%init>
>
> This all works fine - however, my http://localhost/ doesn't load
> index.html even though in my Apache config I have DirectoryIndex set up.
>
> My setup:
>
> Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.8c mod_apreq2-20051231/2.6.0
> mod_perl/2.0.3 Perl/v5.8.8
>
> My Apache config:
>
> <VirtualHost localhost:80>
> ServerAdmin [EMAIL PROTECTED]
> DocumentRoot /usr/local/apache/htdocs/localhost.com
> PerlSetVar localhost.com
>
> <Location />
> DirectoryIndex index.html
> DefaultType text/html
> SetHandler perl-script
> PerlHandler MyApp::Mason
> </Location>
>
> </VirtualHost>
>
> Going to http://localhost has the browser download the file automatically
> with the HTML content.
>
> Must I really put $r->content_type('text/html'); in the dhandler file?
>
> Also, if I set up /admin/index.html and pull up http://localhost/admin/,
> it does not pull the index.html file.
>
> I appreciate any input - terribly confused.
>
> Thank you
>
> Ogden
>
Ogden,
Your Apache config is telling Apache to hand all requests beginning with '/'
to Mason for handling. Therefore, Apache does not do its normal
DirectoryIndex magic, it just hands the request to Mason. (Using localhost
without the slash works because it doesn't begin with a slash, so it doesn't
get handed to Mason).
What I do in these situations is to add code to my dhandler to do the work
normally done by DirectoryIndex. If $m->dhandler_arg is empty, then call the
index.html component and return.
# off the top of my head, untested!
if (!$m->dhandler_arg or $m->dhandler_arg eq 'index.html') {
$m->comp('index.html', %ARGS);
return;
}
Hope that helps.
--
-Vince Veselosky
http://www.webquills.net
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users