[prev in list] [next in list] [prev in thread] [next in thread]
List: mason
Subject: Re: [Mason] Mason Setup with DirectoryIndex and Content Type
From: "Vincent Veselosky" <veselosky () gmail ! com>
Date: 2008-03-27 11:40:26
Message-ID: e218fdce0803270440x3411756cp543b89da48f2257a () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
On Mon, Mar 24, 2008 at 2:20 PM, fixed <onefix@waste.org> 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 localhost@localhost.com
> 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
[Attachment #5 (text/html)]
<br><br><div class="gmail_quote">On Mon, Mar 24, 2008 at 2:20 PM, fixed <<a \
href="mailto:onefix@waste.org">onefix@waste.org</a>> wrote:<br><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;"> I'm having a bit of a problem configuring Apache \
with Mason and having the<br> DirectoryIndex to work.<br>
<br>
My whole objective is to have URLs (which won't exist) such as:<br>
<br>
<a href="http://localhost/mondays" target="_blank">http://localhost/mondays</a><br>
<a href="http://localhost/tuesdays" target="_blank">http://localhost/tuesdays</a><br>
<br>
Therefore, my dhandler is:<br>
<br>
<%init><br>
my $day = (split /\//, $r->uri)[-1];<br>
$m->comp("process_days.mpl", day => $day);<br>
</%init><br>
<br>
This all works fine - however, my <a href="http://localhost/" \
target="_blank">http://localhost/</a> doesn't load<br> index.html even though in \
my Apache config I have DirectoryIndex set up.<br> <br>
My setup:<br>
<br>
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<br> <br>
My Apache config:<br>
<br>
<VirtualHost localhost:80><br>
ServerAdmin <a \
href="mailto:localhost@localhost.com">localhost@localhost.com</a><br> \
DocumentRoot /usr/local/apache/htdocs/localhost.com<br> \
PerlSetVar <a href="http://localhost.com" target="_blank">localhost.com</a><br> \
<br> <Location /><br>
DirectoryIndex index.html<br>
DefaultType text/html<br>
SetHandler perl-script<br>
PerlHandler MyApp::Mason<br>
</Location><br>
<br>
</VirtualHost><br>
<br>
Going to <a href="http://localhost" target="_blank">http://localhost</a> has the \
browser download the file automatically<br> with the HTML content.<br>
<br>
Must I really put $r->content_type('text/html'); in the dhandler file?<br>
<br>
Also, if I set up /admin/index.html and pull up <a href="http://localhost/admin/" \
target="_blank">http://localhost/admin/</a>,<br> it does not pull the index.html \
file.<br> <br>
I appreciate any input - terribly confused.<br>
<br>
Thank you<br>
<br>
Ogden<br>
</blockquote><div><br>Ogden,<br><br>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). <br> </div></div><br>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.<br><br> # off the top of my head, untested!<br> if \
(!$m->dhandler_arg or $m->dhandler_arg eq 'index.html') \
{<br> $m->comp('index.html', \
%ARGS);<br> return;<br> }<br clear="all"><br>Hope \
that helps.<br><br>-- <br>-Vince Veselosky<br> <a \
href="http://www.webquills.net">http://www.webquills.net</a>
-------------------------------------------------------------------------
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic