Laughing at the stony face of gloom

(your instinct can’t be wrong)

Odd apache 404 behaviour

leave a comment »

Oh the legacy systems; just lately we’ve been experiencing a little bit of “what can only be described as” odd behavior. Our Apache server is set up to offer virtual hosts; one of these is a remnant of our yee oldee static site :) For some reason though, the following behavior is being observed.

If you click a link to one of the pages on any site you are thrown to a 404 error page on our primary site.


If you type the url in (or do a “copy link”, “paste (into location bar) and go”) the page loads without issue; subsequent requests – as the page is now cached – resolve fine.

My main suspicion is that some thing’s going a bit askew on the redirect front (see – blame mod_rewrite – just because it is powerful and confusing with it’s regular expressions (but not the sort you hear in bars!))

Detailed setup
We have multiple virtual hosts all being accessed from a primary apache server (say 20 or so); many of these link into our primary http://www.domain (usually with a rewrite/proxy to some location – say http://www.domain/ex/servicename ).

The service that is experiencing the problem was previously known as http://www.some-other-domain (I’ll shorten this ’cause I’m lazy to http://www.sod ) but due to a departmental re-branding is now known as http://www.some-new-domain (and this I’ll shorten to http://www.snd ); however all the content remains the same. Additionally, the http://www.sod and the http://www.snd make use of apache’s ldap authentication to our Active directory service. Additionally, the http://www.sod and the http://www.snd have WebDav publishing enabled (as it saves giving users shell accounts (does anyone other than me call them “shell accounts” still?))

Oh, just as I suspected – we have a couple of lines in our virtualhost file for the http://www.snd site.

RewriteCond %{HTTP_REFERER} /ex/servicename
RewriteRule ^/(.*)?$ http://www.domain/$1 [NC,P,R,L]

Let’s remove these lines and give it a whirl!
Yep – everything seems to work. But these lines were put in place for a reason, weren’t they? (You don’t just go adding things willy-nilly to the old apache configs).

A quick ask around reveals no knowledge.

My suspicions are;
1) the site has been effectively decommissioned – this happens – slowly; but direct access has been allowed to give people access to specific areas that are currently unable to be migrated (online training packages and their ilk)
2) someone fugged up, possibly me.

I do need to do some confirmation – and hunting for reasons (should it be doing this? Has the site been decommissioned ? Why haven’t the content providers been told ? yadda yadda)

Solution – long term
Confirm whether or not the site is decommissioned, or whether there was another reason for the rules being put in place. (Contact point: head of Web Team/head of Customer Services)

Solution – short term
Let’s add in some exclusions to try and say “yeah, keep doing that, but not if it’s _these_ pages”

One of the pages is our antivirus software which we allow to be distributed to staff machines (that avoid our standard network for one reason or another) ; it is accessed by a number of pages – but the important thing is, if a request is made for it on the http://www.snd site, that it passes the request straight to the page.

Currently it’s throwing all content back to the http://www.domain site; so we need to put a rewrite rule in before the existing rule.

Something along the lines of

RewriteRule ^/antivirus(.*)?$ – [L]

ta-da :)
Now we just need to find out why it was put there in the first place.


Written by Mas

May 7, 2008 at 10:00 am

Posted in web servers

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: