I have a really strange behavior while using Mason, for example:
I have an
index.html file ( that contains mason tags like
<% $var %> hello ).
When I'm browsing to
http://bla.com/index.html the variable is translated during compilation.
But there's a strange behavior when I'm browsing to
Though there's no file called
index.html) it still loads
index.html and the entire code is shown as plain/text including the
<% ... %> !!!
What have I configured wrong ?
this is my Apache configuration:
ServerAdmin [email protected]
ServerAlias abc.com www.abc.com
Options FollowSymLinks MultiViews
allow from all
PerlSetVar MasonUseObjectFiles 1
After a ~year I accidently found the answer, so I wanted to share my findings:
The problem was that Mason(Perl) displaying the code itself of another file on the web instead of providing "404 file not found" and I had no idea how to stop it. e.g: when requesting index it shows the code of index.html
The solution is that in my Apache configuration there was the following:
<Directory "/var/www/my_dir/"> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
Apparently "MultiViews" is activated through mod_negotiation.c, which cause the site to search for a pattern of the next-best match in-case the file is not found on the server. ( so from www.site.com/index it found index.html )
But because there's no configuration in the Apache to execute /index in Mason ENV ( no file extension ) , it simply displayed the code ...
Funny :) but the solution was to change "Options FollowSymLinks MultiViews" to "Options FollowSymLinks -MultiViews" and not using the MultiViews.
Found this solution while seen the following response headers:
Content-Location index.html Vary negotiate
The "MultiViews" doesn't have any meaning to me, as it was a copy-paste from a 5 years ago that I simply carried from one web-server to another :)
Why the webserver automagically
However, you could as a work around try to add 'index' (or perhaps rather'^index') to the regex that defined what files should be dispached to
HTML::Mason::ApacheHandler. I do admit it is a bit ugly though.
Am I correct that once you load the
index page and get that verbatim code displayed, once you check out the page info, the encoding is literally
plain/text? Perhaps you need to configure some mime settings to ensure that files without suffixes (files not ending with
.html etc) are not sent to the remote browser at all, not even as