4
Jul/09
7

“You do not have sufficient permissions to access this page” after Wordpress upgrade

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
Loading ... Loading ...

If you’ve done a wordpress upgrade which included either copying another wp database or changing the current one’s table prefix (as well as changing the $table_prefix PHP variable in your config file,) you will most likely be met with this warning when you try to log in:

You do not have sufficient permissions to access this page.

The reason for this is that everything in wordpress that accesses info in the db does so from PHP using the $table_prefix variable, and when you first installed your blog, a couple of options are set in the database that include that value, which makes it not really so dynamic! ;)

After rooting through my db, I found 5 or 6 values that still had the old table prefix in – mostly in the `usermeta` table, but also one in the `options` table. To make sure I got them all, I ran these simple SQL statements in phpMyAdmin to update all the values:

UPDATE `wp2_usermeta` SET `meta_key` = REPLACE(`meta_key`, 'wp_', 'wp2_');
UPDATE `wp2_options` SET `option_name` = REPLACE(`option_name`, 'wp_', 'wp2_');

(note: please be sure to backup your database before you execute any SQL on it – if something goes wrong, there’s not a lot you can do to recover it without a backup!)

In those two examples, assume the original prefix was “wp” and the new one is “wp2″.

With that done, I can now log in to my newly upgraded blog again! :)

4
Jul/09
5

Wordpress 2.8 automatic upgrade fails

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
Loading ... Loading ...

I’ve been trying to update my wordpress blogs from various versions like 2.5 and 2.7 to the newest 2.8 for a while now, but was never able to do it automatically.

Every time I pressed the “upgrade automatically” button, it told me it was downloading the latest file from Wordpress, but it never got any further than that. I logged in to my site using my FTP client and found a 0KB sized file called wordpress2.8.zip in the wp_content folder, so I thought I’d found the issue – maybe the script can’t actually download the file and save it to disk because of permissions. I chmodded the file and then the folder to allow write access, but no joy.

Of course, I could have just downloaded the latest install from wordpress and done a manual upgrade, but there’s about 8 million files in the zip file and I didn’t want to have to upload that to 5 different sites! ;)

After a bit of research, it turns out that the problem is that the auto-upgrade script requires PHP5 to run, and as my sites are hosted on 1and1 servers which default to php4, the script was failing!

So if you’re having the same issue, all you need to do is make sure your wordpress is running on PHP5 instead of 4! If you’re on a shared server and you can’t change the server’s config, you can still tell apache to run your scripts as PHP5 rather than 4 by adding the following line to your .htaccess:

AddType x-mapp-php5 .php

All that does is tells apache to to parse all .php files with the PHP5 parser rather than whatever the server’s default is! So just throw that in the .htaccess you find in the root of your site – put it just after the “# END WordPress” line – save it, upload it and try doing the upgrade again – it worked first time for me! :)

If you’re still having trouble after that, or you’ve got a different solution, please post a comment here and let others know!

10
Feb/09
0

Mod rewrite URL with 2 question marks?

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
Loading ... Loading ...

A colleague asked me for some help with a few RewriteRules in his .htaccess today. One of the links he was trying to rewrite was unusual in the fact that is had 2 question marks “?” in it.

Let’s say the url looked like:

www.site.com/2009/1/is-this-a-legit-url?-i-don't-know?

and you wanted to rewrite that to:

www.site.com/2009/1/is-this-a-legit-url-i-dont-know/

You might think the rewrite would be simple, like so:

RewriteRule ^2009/1/is-this-a-legit-url\?-don%27t-know\?/?$ /2009/1/is-this-a-legit-url-i-dont-know/? [R=301,NC,L]

If you run that though, apache will throw a wobbly and tell you that “The requested URL /2009/1/is-this-a-legit-url was not found on this server.”

The reason for this is the server thinks everything after the first “?” is the querystring, so in this case, the apache is looking for a file/folder called “/2009/1/is-this-a-legit-url” and it will pass the querystring through as “-i-don’t-know?”

Of course, the simple solution would be to just match up to the first question mark in the rule, but that might not always be appropriate – e.g. if the string began with a question mark for whatever reason!

We came up with a cunning workaround for this by matching both the request url and the querystring like so:

RewriteCond %{QUERY_STRING} ^-i-don%27t-know\?/?$ [NC]
RewriteRule ^2009/1/is-this-a-legit-url$ /2009/1/is-this-a-legit-url-i-dont-know/? [R=301,NC,L]

Now, if a request like the original one above comes in, the query string will match the rewrite condition, and the requested URL will match the rewrite rule! :)

Note the extra question mark at the end of the rewritten rule “/is-this-a-legit-url-i-dont-know/? [R=301,NC,L]” – you need that in there to stop the server trying to push the original query string through.

Without it, your URL will be redirected to:

www.site.com/2009/1/is-this-a-legit-url-i-dont-know/?-i-don%2527t-know%3f

Unfortunately, using this method does mean that if you have any variable in the query string that you want to push through, you won’t be able to… Chances are though, that if you have 2 question marks, something’s gone wrong anyway, so this fix is better than nothing! ;)

14
May/08
0

Best Practices for Speeding Up Your Website

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

I’ve been watching/listening to October 07’s FOWA presentations and the latest one I’ve heard – by Yahoo’s Steve Souders – struck me as worth a quick look. Who wouldn’t want to speed up their websites?

Steve describes 14 rules that make up a ‘best practices for speeding up your website’: http://developer.yahoo.com/performance/rules.html

And there’s also a way to use the Firefox add-in, Firebug in combination with YSlow to analyse your sites based on the 14 rules: http://www.getfirebug.com/ and http://developer.yahoo.com/yslow/

We’ve been planning a css/js cache for a while now, but never got it off the ground, still seems that a few of the other rules could provide a good return on little investment.

Healthspark