WordPress Permalink problem

June 8th, 2008

Perhaps like me you’re new to WordPress, and perhaps like me you thought permalinks are a good idea. Perhaps, like me, you changed your settings so that your blog articles which once were:

http://blog.lolyco.com/sean/?p=9

could look like this:

http://blog.lolyco.com/sean/2008/06/08/google-adsense-down/

So you chose your pretty permalink option (there are many other ways of beautifying your blog URLs), clicked on your blog and disaster – you get 404 Not Found for every link. WordPress has a document that can help you, but if, like me, you go blind and are unable to read helpful documents when you’ve destroyed your own work, here is the specific problem I had. If this works for you, you can go back and re-read the WordPress document and see that it had this answer all along. If it doesn’t work, good luck!

I run WordPress on a Slackware server with Apache 2.0 HTTP server. WordPress uses URL-rewriting to convert pretty permalinks into URLs that can retrieve the correct PHP file and pass it a useful reference to your post. Just like the useful WordPress article says, you must have mod-rewrite enabled on your Apache installation. If you didn’t previously compile httpd with the --enable-rewrite option, do it. That wasn’t my problem, as I could see from the ever-handy phpinfo() function.

You can check that the pretty permalinks function is working in WordPress by editing an existing blog entry or creating a new test article. If you’ve set the option on in the WordPress Dashboard, you’ll see a Permalink label that tells you what the new URL will be. If there’s something wrong with your WordPress installation, then the helpful document says you’ll see some warning message here. I didn’t, I saw the lovely URL I so badly wanted to use.

So WordPress thinks everything is OK, Apache seems to be working correctly, how does the Permalink code work? It all depends on .htaccess files in your webservers document tree. WordPress generates rules for Apache’s Rewrite module to convert incoming pretty URLs to something useful. It puts these rules in the .htaccess file in the root folder of your blog. I could see the rules in the .htaccess file, as you’d expect, since WordPress hadn’t complained about anything when it created the Permalink URL. So why aren’t they working?

In my case, it was because httpd, the Apache webserver program, was ignoring the .htaccess file. Why would it do that? If you’re a responsible admin, you may have read the Apache tutorial on .htaccess files. See this excerpt:

When (not) to use .htaccess files

In general, you should never use .htaccess files unless you don’t have access to the main server configuration file.

And that’s it, in a nutshell. If you were previously using only server software that never needed access to server configuration on a per-directory basis, you would have used the

Allowoverride None

directive in your configuration file (usually httpd.conf) to prevent httpd ever following directives in .htaccess files. With this directive in place, those WordPress rewrite rules in your .htaccess files are just never followed. The httpd server tries to locate some content at the pretty URL, and fails.

The solution is easy – for the directory your WordPress blogs are located in, just supply a Directory clause in your httpd.conf like this:

<Directory "/var/www/htdocs/wordpress_root_directory">
AllowOverride FileInfo
</Directory>

Your ‘wordpress_root_directory’ will be different to mine. You could always use ‘AllowOverride All’, but you would be permitting more than you might need. Once I made the change above, all my WordPress Permalink woes were solved.

Google Adsense down

June 8th, 2008

On my way to bed, thought I’d check AdSense one last time but got:

Google AdSense

The Google AdSense website is temporarily unavailable. Please try back later.
We apologize for any inconvenience.

Even the big guys have bad days.

So I had a quick look at the Google Blog Search to see what others were saying about the downage, and followed the link at the bottom of the page About Google Blog Search and saw the item about ‘How do I get my blog listed’. In there is a link to the interesting-sounding Google Blog Search Pinging Service so I clicked it. And I got this:

Google
Google Help Center
Test123

I think Google needs to work longer Fridays! Come on guys, finish things before the weekend!

PS. I wrote this blog entry, saw an option for ‘Pretty Permalinks’, set it and went to bed. The blog article was inaccessible until the next day… I should take my own advice.

osCommerce-2.2rc2a

June 7th, 2008

Installed the latest stable osCommerce distribution today, on a new domain. It’s a slightly newer version than the one that’s providing the Lolyco.com shop. The installer is a breeze. There’s a chance I overlooked some of the installer’s complaints last time. On the front page of the installer there’s a ‘Server capabilities’ box:

osCommerce install Server Capabilities Box

I use cURL and OpenSSL almost daily, so I know the core software is installed for those two. The ‘slackpkg’ command tells me I also have GD installed. PHP is installed from source on this server, and a quick check of ‘./configure –help’ tells me there are command line arguments to switch on support for these extensions that I didn’t previously use.

I usually keep a text file hidden away somewhere that I use to make notes of all the substantial changes I make to my servers, to refer to in cases like this. That text file can be vital in a catastrophe too – if you can’t get an image of the server software running on a replacement machine, it can be useful to know how to rebuild the server software from scratch. If you don’t keep notes, but you don’t delete your source trees after you build them, you can often find a copy of the configure arguments you last used in a file called ‘config.log’.

To add the support for the missing extensions, all that needs to be done is to reconfigure the makefiles by adding

--with-gd --with-openssl --with-curl

to the configure arguments. To see the effect of the changes, complete the PHP make and install process, and restart your webserver (I forgot this last bit for a few heart-stopping, dizzying moments when all the sites on this server stopped working. Remember kids, don’t work on production servers!).

Once the osCommerce install page was refreshed, all those red crosses had turned to ticks. After setting up a MySQL database for the osCommerce shop, and filling in the database credentials and location on the installation page, you’re finished – osCommerce is installed and ready to go!

Installation really couldn’t be made much simpler, in my mind. Which is why the first view of your new online shop is such a shock – it’s UGLY! Unlike many other open source projects that support you in changing the look of your website, osCommerce provides no built-in help at all for changing the theme of your sites. There are lots of very cool open source themes you can use though, just visit the osCommerce Templates and Themes collection. I’ve got to confess to giving up with this option – the first theme I saw that I liked required the complete replacement of all the PHP code in the whole project. If you’re at all bothered about the security of open-source projects, that’s exactly the sort of thing you should avoid like the plague.

I resorted to copying and modifying the theme from Lolyco.com – maybe this can be a little time-consuming, but this is what makes open-source great, in my mind. I can take something I’ve used before, modify it to fit a new need, maybe even improve both sites while I’m at it. Once I’ve setup the look of the site, I just need to copy across some shipping and payment methods, setup the products and the static content of the site (terms and conditions, about us – that kind of thing) and I’ll be ready to sell! Stay tuned for part 2.

Where are you all coming from?

June 6th, 2008

People ask me where I’m from. I’m from the UK. I grew up in the South East of England, on Canvey Island in the Thames Estuary. Around age 20 I moved to the Lake District, and settled for a while near Lancaster. I have very fond memories of Lancaster and the surrounding areas. Of all the places I’ve been in the UK, Lancaster is the place I think of as ‘home’. I no longer have a house there, but this is what my home looked like when I lived there.

9 Moorside Road

The house was about 200 years old, and is part of an extension on a house built in 1770. The original house was divided into 3 separate dwellings long ago. There are 2 small rooms upstairs, and the area downstairs is just under 6m x 4m. I miss my Renault Clio. I’ve been driving a Proton Wira in Malaysia for the last 2 years. It’s a pity Malaysia wasn’t a French colony. The cakes here could be better too.

TM Net SDSL to Residential address

June 6th, 2008

After a warning from one of the regular posters at WebMasterMalaysia, I checked the Terms and Conditions for my Streamyx service. There’s no prohibition of home servers in there, so that’s a relief. The search for increased upstream bandwidth goes on though.

I phoned 1-300-88-9515 today, and Edward checked with his supervisor and was told they had no objection at all to SDSL service (only sold as Business Broadband) to a residential address. They recommend a visit to my local TM Point in Port Dickson though, so the practicalities of getting the new line installed might be a totally different matter.

TM Point says they have to ask a technician, which seems reasonable. But they also said a house near Glory Beach enquired and were told ‘no’. No seems a bit harsh for something you pay for – surely it should just cost more? We’ll have to wait and see. If there’s anybody out there who has a cunning plan for upstream bandwidth above 1Mbit/s in West Coast Malaysia, I’m all ears! It’s unlikely there’ll be any competition for TM outside of KL or Penang though – without access to trunk routes, there’s nothing anybody can do. If you’re in the lucky position of having some reasonably-priced trunk route access, and you want a cunning scheme to get subscribers, drop me a line. I can think of dozens of subscriber access schemes around 10Mbit/s that would work a treat in Malaysia.