Tech


Help, My Permalinks No Longer Work!

I’ve been using the following permalink construct since I first started this blog:

/%category%/%postname%

At some point during a recent upgrade this had the effect of making every single page, post, category page or tag return a 404 Page not Found error.

And not my custom 404 page either but a server 404 error page, even my 404 page was no longer working! Unfortunately I didn’t realise this until I fixed everything, so I missed out on the existential fun of having a 404 page throw a 404 error itself!

 

/%category%/%postname% Considered Harmful?

According to the WordPress site it is (now?) not considered good practice to use this construct. Hmm… I’ve been using it for years and never had an issue with it so I don’t care about that, and I have one post that is very widely linked and referred to, so if I change the permalink structure I’ll need to put in a permanent redirect just for that post. I just want my blog to work again thanks.

There seem to be an awful lot of people out there reporting this same problem, with various levels of similarity to my issue, but finding an actual solution took a fair bit of effort / trial and error; going through the usual process of troubleshooting – disabling plugins, switching permalinks back to the default, switching to the default theme etc. didn’t throw any light on the problem.

 

The Mystery Deepens…

I was able to narrow the problem down to the RewriteRules required for the permalink constructs to work. According to the permalink settings page these should be in my .htaccess file in the root level of my wordpress directory.

The odd thing is, there was no .htaccess file there, and neither were there any RewriteRules in my virtual host config file, so I do have to wonder how this ever worked.

Is it possible it was a new “feature” introduced with the upgrade to 3.x that I never noticed? I admit I hadn’t updated for a while and ran the upgrade to 3.something-or-other recently, when I was very busy and not paying attention – who hasn’t just logged in and seen that an update was available, clicked through the Update Automatically process and thought no more about it, right? Alternatively, perhaps the upgrade process somehow removed the .htaccess file?

Anyway, I altered the permissions to allow WordPress to create a new .htaccess file for me, but still had no joy, every link still gave the same 404 error.

 

The Solution

After much head scratching I eventually figured out that the Apache setup did not recognise the presence of the RewriteRules in the auto-generated .htaccess file. I have no idea why as it wasn’t giving any errors, it was like it couldn’t even see the file. This is odd in that I’ve used various .htaccess files on my sites over the years, including complex RewriteRules to block a widespread content leaching problem, and have never run into this issue before.

The solution for me was simply to add these rules to the virtualhost config file and restart apache, and hey presto all my links suddenly work again thank you very much!

The relevant RewriteRules section to add is as follows:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /index.php [L]
</IfModule>

Obviously set the RewriteBase to the folder you have installed WordPress into if it is not at the root level of your site.

I have no idea what changed or why the .htaccess file was no longer working, but hopefully you might find this information useful if you’re in a similar pickle!

This is awesome:

(via IceTV)

Important Service Announcement

Channel Seven and Channel Nine are set to launch their latest channels

7mate on the Seven Network

Billed as being a “bloke-friendly” channel which promises to clear backyard sheds across the nation.

Programming on the channel is set to include first run episodes of popular shows like Gene Simmons, Family Jewels, Punk’d, Nitro Circus, American Dad, Family Guy, the list goes on.

GEM on the Nine Network

GEM is targeted at the 35+ female market with a mix of new content, classic comedies, cherished drama series, all-time favourite movies, and oddly all of Nine’s sport coverage in high definition.

I spent years wondering why there aren’t timestamps in the bash history file, and why there’s no obvious way to add them as they would be so fundamentally useful.

Turns out there is a nice easy way to do it after all:

Set HISTTIMEFORMAT to some suitable string in your .bashrc, ie "%F %T", this puts a unix timestamp in the history file, and displays your easily readable format via the history command.

As usual, if you think something is worth doing then the chances are, someone’s already done it and you really should just go and look!

More bash stuff in the wiki

The wiki is finally online. Had a slight legacy issue with versions of PHP between my dev and live environments that took a little while to work out.

There are still a lot of gaps in the wiki, and quite a few dead links, but they should be sorted out in the next couple of weeks as I port the content across.

Meanwhile, if you find anything that is broken or any info that is clearly wrong, please let me know.

www.rootdev.com/wiki

What’s Wrong With Nagios?

Don’t get me wrong, I like Nagios. I think it’s an excellent piece of software and I have spent many years working with it, but I have just completed a proof of concept and gained approval to deploy OpenNMS as a new Enterprise Grade Network Monitoring System. And the main system targeted for replacement here? That’s right, it’s Nagios, which is primarily running via the remote plugin model, using the NRPE daemon to run scripts on remote hosts and report back to base.

Now anyone who has ever played with Nagios will know that it can be a beast of a thing to set up and get working satisfactorily. In fact, most places will devote a good year or so to the process. As a newbie, sitting in front of a freshly installed Nagios instance and wondering how to get it to do something can be an extremely disheartening experience. Once it’s up and running though it’s usually fairly low maintenance to keep it going, and not too difficult to add new devices or custom plugins as you go along. And, for the most part, it is good at what it does, so why would you want to replace it?

Well, despite having almost unparalleled abilities to monitor at the application level and perform any manner of esoteric checks, Nagios does have its limitations.

(more…)