My Netfirms Permalinks Are Pretty

[This post it outdated! Please see my WordPress plugin that enables pretty permalinks. This post is for informational purposes only]

OK, so this is mostly for any other users who maybe on Netfirms like me.

For some weird reason, Netfirms does not support “pretty” permalinks in WordPress, despite the fact that they claim to have Apache mod_rewrite enabled (Maybe because AllowOveride isn’t enabled, who knows). That’s why for the last month all of my links have been that crazy, ?p=123 or whatever the heck the post number was. Well, after Netfirms Tech Support was of no help (as usual), I decided to do my own research and hack around a bit. 5 hours later, viola! Pretty permalinks!

So how did I do it? Basically, I tricked WordPress to apply it’s internal mod_rewrite rules as if I was passing path_info (the only permalink structure Netfirms supports), and rewrote the mod_rewrite rules to rewrite all the urls to use path_info (try saying that sentence 5 times fast). And guess what, you can do it too! Just follow these easy steps below! (Obviously, I make no claim this will actually work on your own site, and you will actually be adding a line of code into WordPress, so please know what you are doing. This also means if you update WordPress, you will break this little hack. I’m using this on my own installation of WordPress version 2.0.4).

[For WordPress 2.1, 2.2, follow the Update 2007-01-26 instructions]

  1. Log into your WordPress admin and choose your log awaited permalink structure.
  2. WordPress will then hopefully create a .htaccess file for you with some mod_rewrite rules. If not, create a blank .htaccess file at the root of your WordPress installation.
  3. Copy the following mod_rewrite code below and replace the WordPress generated rules with it. Also, remember to change the RewriteBase to your WordPress directory:
    Code (apachelog)
    1. RewriteEngine On
    2. RewriteBase /
    3. RewriteCond %{REQUEST_FILENAME} !-f
    4. RewriteCond %{REQUEST_FILENAME} !-d
    5. RewriteRule ^(.*)$ index.php/$1 [L,QSA]
  4. Open wp-includes/classes.php and find line 1543 or so. It should read something like:
    Code (php)
    1. foreach ($rewrite as $match => $query) {

    Directly after this, add this small piece of code:

    Code (php)
    1. $match = ‘index.php/’.$match;

That’s it! Congratulations, enjoy your new pretty permalinks, you lucky Netfirms dog you!

[UPDATE 2006-11-10] This hack above also works with WordPress 2.0.5.

[UPDATE 2007-01-26] It looks like those crazy developers over at WordPress changed a bunch of things with the new 2.1 release. The hack still works, just the line numbers have changed.

  1. Like before, modify your .htaccess file with the new mod_rewrite rules found above. Make sure to set the RewriteBase to the correct settings for your server.
  2. Lock your .htaccess file down! Before, WordPress didn’t touch your rewrite rules unless you changed it in the administration options section. Now, it seems like it will try to update them even if you aren’t in the options section. So chmod your .htaccess file to 444 or a setting that PHP can’t write to.
  3. Find the classes.php file and open it in your favorite text editor. You can find it in wp-includes/classes.php.
  4. Look for line 86 or so. It should look like this:
    Code (php)
    1. // Look for matches.
    2. $request_match = $request;
    3. foreach ($rewrite as $match => $query) {
  5. Add this line of PHP directly after:
    Code (php)
    1. $match = ‘index.php/’.$match;

That’s it! Ben reported that he was able to get pretty permalinks working by just adding the mod_rewrite rules above for PHP4. I am using PHP5, and I needed the full hack to get mine to work correctly. But you might want to try just adding the mod_rewrite rules above first and see if that works for you.

[UPDATE 2007-08-14] Since I’ve been too lazy to create a decent plugin for this (or maybe I’ve been too busy :-p), I’ve uploaded a hacked (or patched if you want it to sound nicer) classes.php file from the WordPress 2.2.2 release. You can simply download this, and upload it over your old classes.php file in wp-includes. You’ll still need to follow the .htaccess instructions above, since you’d have to enter in your ReWriteBase anyway. Also, this classes file is only for PHP5. If you’re running PHP4, only follow the .htaccess instructions.

Download the patched classes file here

trackback | permalinkComments Feed


20061102 10:42

HA! That’s why I use GoDaddy!

Actually, not it’s not. I use GoDaddy because it’s cheaper and because I am too lazy to switch it. And also, I am not a code-monkey, so if there are problems, I just smile and nod and keep on ignoring them.


20061108 01:10

I installed WordPress 2.05 manually and it permalinks worked right away without modifying any code. I had to make sure .htaccess is enabled in the control panel.

I went into WordPress admin and clicked Option and Permalinks. Then selected “Date and name based” so the urls will look like


20061108 07:29

Hi Sam! Thanks for the heads up! Perhaps there has been a change in the new 2.0.5 release (since I haven’t updated yet) in regards to Netfirms users.

For me in WordPress 2.0.4, if I just pick a standard permalink structure (like the Date and name based) and not follow the custom structure outlined here by Netfirms (, the links don’t take me anywhere but back to the home page. I have to enter the “/index.php/” in the permalink structure, and the links end up looking like this which I don’t want in case I move servers or change blogging software in the future.

Once I update to 2.0.5, I’ll update here with my results. 😀


20061110 09:36

Just an update. I downloaded the newest version of WordPress (2.0.5), and the “pretty permalinks” do not work without adding the /index.php/ into the permalink structure like Netfirms support article states (see above comment for link).

My hack above works with WordPress 2.0.5 and will allow Netfirms users to achieve pretty permalinks with any structure that they choose. (Obviously, if you don’t use Netfirms, then you probably don’t need this hack unless your host requires you to modify your permalink structure for them to work)

Sam, perhaps you are on a newer box than me? If so, you are lucky and I wish I could be moved too!


20061122 09:13

Computers are hard to figure out. Always screwing with me. I wish I could kill a computer and the computer’s family would be sad.

Ben Requena:

20070124 02:00

I’m getting an error message repeated on my page:

Warning: Division by zero in /mnt/w0507/d13/s04/b01becc2/www/wp-includes/classes.php on line 1548

So….where did I go wrong?

Ben Requena:

20070124 02:07

Hmm… Spooky. I’m running WP 2.1 and I didn’t need to place in the extra bit of code into the classes.php file to get the new permalink stucture to work properly.


20070124 03:21

Hi Ben (I like your site design, by the way),

Thanks for the heads up! I just downloaded WP 2.1 to do a quick test myself, but for some strange reason, I still can’t choose one of the canned WP permalink structures like “Date and name based”. I have to enter a custom structure starting with /index.php/ for the permalink to work (as outlined by Netfirms). Very depressing.

Are you by chance using PHP4? I saw the Netfirms support article (linked in my above comment) was updated last month with a disclaimer about PHP5 (which I am running). Maybe that is my problem, because WP still doesn’t seem to work “out of the box”, and I don’t want to have “index.php” in all my of permalinks.

I haven’t tried my hack above in WP 2.1, but I will when I have a chance and post the result here. It looks like 2.1 is a solid upgrade though!


20070125 11:25

Thanks Joel.
Yeah, I’m using php 4.

The out of the box solution didn’t automatically fix my permalink problems either, but once I added in your rewrite code it worked like a charm. I didn’t need to edit the php at all.


20070126 10:36


I was updated the “About Us” page and noticed they weren’t working with the current permalink settings. I’m not knowledgable enough about all the parts to know what’s causing the error, but I do know that the default permalink structure doesn’t cause the problem so I’ve left it like that for now.

Ugh! I’ll think about switching hosts when my year is up.


20070126 02:47

Hi Ben,

I was playing around a bit with WP2.1 to see if my hack above would still work with it (which it does by the way), and it seems as if WordPress will now try to modify your mod_rewrite rules if your .htaccess file is writable, regardless if you are in the permalinks options window or not. So you might want to check if your mod_rewrite rules were changed without your knowledge. You can reapply my rules above, then lock your .htaccess file down by chmoding it to 444 and you should be good to go.

I’ve updated my original post above to reflect the changes in WP 2.1. Hopefully, other Netfirms users can get this to work too.

I’ve been pretty disappointed in Netfirms lately. When I first signed up 6 years ago, they were great. Now, MySQL servers are butt slow and they really aren’t helpful at all. I would have switched to a new host this past year, but I waited too long to migrate all my accounts. I probably will this year though. Sad, really.

Jason Poitras:

20070215 02:21


I installed WordPress 2.1 on Netfirms and I am running into the same issue.

The permalink custom structure I am trying to use is: /index.php/%year%/%monthnum%/%day%/%postname%.htm

I’ve edited the .htaccess file as per your instructions, keeping in mind that I have to edit the ReWrite base. This is what I have:

# BEGIN WordPress

RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

# END WordPress

Problem is I still see the index.php in the link. Any other ideas?


20070215 11:21

Hi Jason,

Your .htaccess file looks correct. All that is left to do is to log back into Netfirms and remove “/index.php/” from your permalink structure so it looks like this “/%year%/%monthnum%/%day%/%postname%.htm” and you should be good to go.

One word of caution, make sure you CHMOD your .htaccess file to 444 before you start poking around in the WordPress admin section. New in 2.1, WordPress will try to check if your .htaccess file is writable, and if it is, add it’s rules back into your .htaccess file even when you’re not in the Permalinks section. So you might want to triple check your .htaccess file and make sure the new rules are still in there.

Hopefully after this, you should be set! Let us know how it works for you, or if you need any thing else 🙂

Jason Poitras:

20070215 11:47

Thank you, thank you, thank you. That did it!

Now I can get back to building my site.

Thank you Joel!


20070216 09:12

Hi Jason,

I’m glad it worked (mod_rewrite can be such a pain in the butt)! Just out of curiosity, are you running PHP4 on Netfirms, and did you just apply the mod_rewrite rules? I am trying to get that squared away once and for all. Thanks!

You’re site is looking great by the way!

Jason Poitras:

20070217 12:30

1) I applied the mod_rewrite rules that you suggested. My .htaccess file looks like this:

# BEGIN WordPress

RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

# END WordPress

2) I then CHMOD the .htaccess file to 444.

3) I then logged back into WordPress and removed the index.php from my custom permalink structure. I ended up using this: /%year%/%monthnum%/%day%/%postname%.htm

4) After you update the structure, you will get a message from WordPress indicating that you need to manualy update the .htaccess file. This message can be ignored.

I have my account setup to use PHP 4. Once again thank you for the help.


20070401 01:48

im also with netfirms and had the same problem but your solution broke my blog and returned a php error saying division by zero then i thought of going step by step, then just changing the htaccess contents and setting the structure back to Date and Name worked
i have a detailed blog post about this on my blog


20070401 05:38

Hi angrys0ul,

Yeah, I’ve had others report the same PHP error as you, and the reason it happens is because if you just copy and paste the code above, Texturize in WordPress makes the apostrophes into curly versions that the PHP parser doesn’t like. You’d need to replace the curly apostrophes with plain, non-curly ones:

$match = ‘index.php/’.$match;

Annoying, I know, and I should really make a WordPress plugin for this hack so it is easier for everyone, but I just never have the time. I’m glad the .htaccess rules worked for you though! » Blog Archive » Wordpress Permalinks Working:

20070424 09:39

[…] much searching I came accross teh following site: Through some additional trials I determined that by adding the following line ($match = […]

Andrew, Sqwink Design:

20070428 10:03

QUOTE: Hmm… Spooky. I’m running WP 2.1 and I didn’t need to place in the extra bit of code into the classes.php file to get the new permalink stucture to work properly.

Yeah, I’m on 2.0.1 on Netfirms, and my ‘pretty’ permalink-structure works fine too??

Netfirms Wordpress and Pretty URLs (Date and Name) « Anything, but not Everything:

20070430 03:30

[…] to what i have done to get my Date and Name permalinks back, i tried the workaround provided by Joel, who is another frustated Netfrims-Wordpress user. And the result is it didnt work. But i suggest […]

Ilya V. Azarov:

20070722 04:19

I’ve same problem with WP. Clients want article name in URL 🙂

e.g. /2007/07/22/hello_world/

So, all works fine on PHP4 but does ot work on PHP 5.

I do not like rewrite code inside WP – it’s difficult for understanding and going write nice plugin workaround…


20070722 09:06

seems to have worked for us over at, thanks!


20070814 02:06

I’ve been trying to fix this for days, just came accross your solution and just applied it…but no change to the permalink error!
Is it true that it doesn’t work with PHP 5? and are there any further suggestions you might make?
Feel free to e-mail me. We really have to get Netfirms to fix this…I have a record-breaking support thread at over this issue and now they hate me for hosting with Netfirms!


20070814 08:49

Hi Amana,

Not true! 🙂 This hack does work on PHP5 as well (that’s what I’m running this site on). There is just the additional step of editing the classes.php file per the instructions above. I know this could be a little daunting for some users, so I took the liberty of uploading a hacked classes.php file from the WordPress 2.2.2 release (I really need to make this a plugin though… I just keep saying that).

Simply unzip this file, and upload it to your wp-includes folder (making sure the filename is classes.php), then follow the instructions for the .htaccess file above (don’t forget to change the file permissions), and you should be good to go. Don’t forget to report back here with any success or if you need any more help.

I’ve been with Netfirms since 2000 – 2001, and in the past they’ve been great to me. The end of last year and most of this year however, their service has been horrible (thanks to slow MySQL servers). It seems as if things have been getting better, but just as I was coming here to post this, my server was down for about 5 – 10 minutes. So yeah, I’m probably going to be moving myself in the next couple months, but I also want to upgrade to something where I can install my own PHP extensions 🙂


20070814 01:36

Well, I must have done something wrong. I edited the classes.php per instructions and even had the error with the curly quotes, which made the page go nuts until I changed that. Maybe I edited the .htaccess improperly? It’s now set to 444.


20070814 02:17

Hi Amana,

Just curious, were you editing the patched file above, or your own non-patched classes.php? The instructions above were already applied to the patched file, so you don’t need to make them again. I would just try downloading the patched file, overwrite your old classes.php file with it, then finally edit and lock down your .htaccess file again.

Also, if you didn’t remember to chmod your .htaccess file to 444 right after you edited it, I would double check it just in case. Even if you are just clicking around in the WordPress admin, it could be overwriting your new settings. It’s greedy like that 😉

Hopefully that will do it for you 🙂


20070814 02:49

Well, I tried both ways. I think I’m not using the .htaccess correctly, I’ve tried every variation of instructions, but nothing works. Now I get the error
The requested URL /myblog/index.php/my blog/index.php was not found on this server.
Curently chmod is 444, and I’m using your version of classes.php.


20070814 03:01

Hi Amana,

Could you post the permalink structure you have entered in the WordPress Admin? Also, can you post your .htaccess file? I’ll take a look at it and see if I can see anything wrong. The server definitely shouldn’t be looking for two ‘index.php’.


20070814 03:11

Okay, I just changed chmod to 644 and the permalinks structure to /%postname%/ from index.php/%postname%/
I just turned permissions back on, so I bet WP rewrote the rules I was using in .htaccess.
I was using the .htaccess rules from the comment above; the rules you orginially provided were rejected by the server (STOR command?)
How should I write the .htaccess, and in what order should I:
write the .htaccess rules and save them
change permissions
change permalinks
My other problem may have to do with my root dirctory .htaccess. In response to what may be bad advice, I am trying to also use that file to provide instructions; should I only be modifying the blog .htaccess or both?


20070814 03:42

Hi Amana,

You are correct. If you have your blog in a sub-directory, you’ll need to edit the .htaccess file in that sub-directory (because WordPress will try to edit it anyway). Obviously, just make sure your RewriteBase is set correctly.

I’d edit the .htaccess in this order:

1. Change permalink setting in wp-admin
2. Edit .htaccess file per instructions above
3. Lock down .htaccess to 444 permissions

The trick is to not click around in wp-admin after step 1. That way you won’t risk WordPress overwriting the new settings until you lock it down. Let us know how it works. Good luck! 🙂


20070814 04:07

Here’s the .htaccess file I just used following your directons above:

# BEGIN WordPress

RewriteEngine On
RewriteBase /bookofmoron/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

# END WordPress

I now get the same error I was getting before. Seems like a code loop.
The blog in question is at:


20070814 08:57

Hi Amana,

Your .htaccess file looks fine to me. Honestly, I’ve never played around with using a double .htaccess files, so I would disable the root .htaccess mod_rewrite rules and just try to get your subdirectory working correctly. That way we can determine if the mod_rewrite rules need to be place in the root .htaccess, or in the sub-directory one. You can do that by editing the line that says RewriteEngine On to say RewriteEngine Off in your root .htaccess file.

Ah, mod_rewrite… it’s such a pain in the butt, yet so absolutely wonderful when it works! 🙂


20070814 09:35

I deleted the root directory .htaccess (it only contained the WP instructions) but still no change.
I think a Netfirms all-in-one plug-in would be highly valuable and I personally would promote it.
Thank you for all your help so far…I am so jealous of your functioning comments!


20070815 10:50

FINALLY got it to work using this in my .htaccess:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index.php
RewriteRule (.*) index.php/$1 [L]

# END WordPress

Thank you so much Joel for your help…you’ve been a lifesaver.
P.S. can’t wait to see that plug-in for the next upgrade (or will I find a way out of my netfirms slavery?)


20070816 08:21

Hi Amana,

I’m happy you finally got your permalinks working, and the site looks great! 🙂 That’s interesting that you had to add that last RewriteCond. I wonder if it is something unique to the double .htaccess.

Thank you for sharing your findings here! I’m glad it finally all worked out!

Joelika » Blog Archive » Hello Server:

20070926 09:06

[…] those of you who are using my Netfirms Pretty Permalink Hack for WordPress, well, obviously I won’t be able to test it with new versions of WordPress after November. […]


20071005 09:44

I can’t get this to work with WordPress 2.3 Do you think you could try out wp2.3 before you leave Netfirms?


20071005 04:09

Hi Steve,

I just downloaded the WP 2.3 release, and I see what you mean, those developers have changed things again! I’ve started to track down what the issue maybe, so I hope to post a WP 2.3 patch for Netfirms soon. Also, I plan on creating a new write up as well before I am on my own VPS. Of course if you discover anything yourself in your testing, please let me know! 🙂


20071007 06:42

Hi Joel, great work so far.

I’ve had all running well on WordPress, (thanks to your sugestions), before the recent 2.3 upgrade.

I spent a day or so puzzling on the dreaded infinite loop error that was popping up, and came across this post when trying to figure out what was going on:

Do you think the recent problems may include the fact WP has switched to forced canonical urls?


20071007 07:00

Hi Wakefield,

Wow! Thanks so much for your comment! 😀 You totally hit the nail on the head with the forced canonical urls! I noticed the looping problem as well on Friday when I first started looking into it, but I just thought I’d have to load WP with xdebug and see what was calling wp_redirect and comment it out. You saved me a ton of time!

So to get WP 2.3 running on Netfirms with pretty URLs, first you need to install the disable canonical URLs plugin from Mark (see the original link from Wakefield for more info), then apply the same hack we all know and love from my post above (same .htaccess rules, same classes.php hack as WP 2.2, just different line numbers) and you should be set.

I am seriously trying to make a plugin to do all of this, so I won’t update this page (except for this comment anyway) with the WP 2.3 info until I create a new post for the plugin. Like I said, this will be done before November when I move off of Netfirms.

Thanks so much again Wakefield! 😀


20071007 10:20

Just a quick FYI, I did create a WP plugin tonight that finally makes pretty permalinks work on Netfirms with a simply drag and drop installation. I have it tested with WP 2.3, and I will be releasing it here in the next day or two, once I have time to whip up a read me. So no more editing the classess.php or locking down your .htaccess files, which is a good thing. Hooray! Stay tuned.


20071008 09:52

I’ve just release my WordPress plugin that enables pretty permalinks on Netfirms. Please direct all further discussion regarding Netfirms Pretty Permalinks to:

Thanks! 😀