13 March 2012

Apache "AllowOverride None" confusion

Background

We had a situation where, there was a Apache Server with virtual hosts configured, one of the virtual hosts  was located at

eg. /var/www/mysite

Under there was another media folder called media.

/var/www/mysite/media

I wanted to serve the media as a separate virtual host.  The basic configuration was easy enough, just create a separate symlinked virtual host configuration file in /etc/apache2/sites-enabled for the new media site.

What went wrong

Everything seemed to work fine if the files (jpgs) were found in the media folder they were returned to the client as expected, however if a file was missing the server was generating server redirection errors, instead of 404s.

This was causing me to tear my hair out.  Why redirection errors?  There was no .htaccess file in the media folder, and in the directory section in the virtual host configuration "AllowOverride None" was set.  So I was reasonably expecting that no .htaccess file would be processed for this virtual host, and as there wasn't one in the media folder anyway, I couldn't understand which rules was it processing to end up with redirection errors.

What was really happening

AllowOverride None meant that no .htacces directives in the media folder were being applied, but because there was an .htaccess in the parent folder for the site virtual host, those rules were being applied instead, which is where the redirect rules were located causing the redirect fail.

How to fix

Adding another directory section to the virtual host config did the trick, this prevented the parent .htaccess file from being processed.

[Directory /]
   AllowOverride None 
   Options None
[/Directory]

*angle brackets changed because of blogger

(If you want to be really restrictive you should add "Deny from all" in there too, just make sure you add "Allow from all" in your home directory section )

Why the fix works

.htaccess files are processed from the current folder to the parent folder and all the way up to the root folder (of the disk!). Setting "AllowOverride None" on /var/www/mysite/media meant that in the media folder and down, no .htacces files are processed, but they still inherit from the parent folders.

Setting the AllowOverride None on the root folder meant that no .htaccess files are processed except those in the folders that I explicitly allow.



01 March 2011

Magento

Some say its a Great CMS for eCommerce applications.

I say it's a complicated, over-engineered, undocumented, stress inducing monster from the pit.

grrr

11 August 2009

I Hate EMACS

EMACS is a text editor, that's about all I know about it. Today I was using subversion source control in OSX. I did a simple commit, and bang, up pops emacs wanting to type a commit message. I didn't know it was emacs at the time, it was just some kind of editor. I didn't need a (useful?) comment, so I just wanted to quit. That's when I got annoyed. I thought that Microsoft had the monopoly on computer annoyance nowadays, but how wrong I was. All I wanted to do was quit, close the program, return to the command line.... How ******** difficult can it be to quit a program. Ctrl-C, Ctrl-X, Ctrl-Z, Escape, Alt-C, Alt-X, Alt-Z, Cmd Q, Cmd C, Cmd Z, F1, F2, F3, etc. Escape, Escape, Escape, aarrrgh.

There is a menu bar, but I cant access any of the options, occasionally the cursor moves, but I don't know why. Finally I somehow hit a random selection of keys that meant the thing quit, but I had to type 'yes' instead of just hitting 'y' to confirm that i didn't care that the text was about to be unsaved and thus heading for damnation.

WTF! Is it still 1978?

I appreciate that emacs has a long and historic pedigree, similar to vi(m). I understand that power users don't want to touch that new fangled mouse aberration that is attached to the machine. I understand that text only interfaces are the true and only way to computer nirvana.

In this day and age, there is NO reason to have SUCH a confusing and impossible to understand interface. Some might say it ain't broke, so there is no need to fix it. I would say it IS broke, very very badly.

It's not that I can't learn to use emacs, or just 'rtfm', it's just the annoyance that when I get into the program by mistake, there are no helpful or easy hints how to get out of the program, and it is inconsistent with most others editor out there.

All it needs to do is when someone hits ctrl-c is to say 'Quit without saving? y/n', I tap 'y', and the program quits. Fast, easy, efficient, and consistent.

/rant over