Fun with htaccess

The content of this post refers to my old host, Beigetower. Some of the things here don’t apply. As always, I take zero responsibility for outdated content. You’ve been warned! :)

I realize that my site has been crashing all day. Sorry about that. (Miraculously, Saille managed to leave a comment right in the midst of all this hoodah. Nicely done!)

The goal: Super-Ultra-Mega Clean Permalinks
I want the links on my site to be as ultra clean as possible. Here’s what I’m thinking for a URI scheme: will bring you to the “all blogs” page that I’ve always kept in the index.php. will bring you to my main blog, #2. BUT, there is no “/blog”, there is only “/blog.php.” (For some reason, I’m reminded of that little bald kid in the Matrix. “Once you realize that there is no .htaccess, then it is only yourself that Rewrites.” Playing with regexes’ll do that to a guy.) will show all the posts in May, 2004. will show this post.

As you can see from poking around the links here, I’ve got it pretty much there. I stuck this in my .htaccess file:
# Extra Super Duper Clean URLs
RewriteRule (^[^\./]+)$ $1\.php
RewriteRule (^[^\./]+)/([^\.]*)(.html)$ $1\.php/$2$3
RewriteRule (^[^\./]+)/([^\.]*)$ $1\.php/$2
Then, in the backoffice, I stripped the “.php” from the stub url/names of all my blogs. Beautiful.

Except that I can’t go into the backoffice to write anything. It says “admin.php” could not be found.

So, I added this sloppy crap to take care of that problem:
# Cleanup Unwanted the RR Tracks
RewriteRule ^(admin)(\.php)/(.*) $1/$3
RewriteRule ^(skins)(\.php)/(.*) $1/$3
RewriteRule ^(ari)(\.php)/(.*) $1/$3

In 0.9, you can display a blog by passing the name of the stub file to a slick little script that they stuck in index.php. With that feature, and my newly acquired .htaccess wizardry, you can visit and see blog #3. I can set it up to view that way, and then get rid of the stub file.

But, “index” doesn’t mean anything. Also, doesn’t show you the posts in May, 2004. It returns a big fat 404, stating the “2004.php” could not be found.


Here’s what I want for a scheme:

  • If there’s no folder named foo
    • If there’s no script named foo
      • Rewrite to /index.php/foo/bar/1/2/3
    • If there’s a script named foo.php
      • Rewrite to /foo.php/bar/1/2/3
  • If there’s a folder called foo
    • If there’s no folder called /foo/bar
      • If there’s a script called /foo/bar.php
        • Rewrite to /foo/bar.php/1/2/3
      • If there’s no script called /foo/bar.php
        • Rewrite to /foo/index.php/bar/1/2/3


Maybe I’ll fix whatever I broke with _feedback.php for this skin. For now, if you wanna leave a comment, and you don’t see a form below, drop it in another skin. To quote the Immortal and All Powerful God, in his last great and firey words to humankind,
Sorry for the inconvenience.

2 Responses to “Fun with htaccess”

  1. On May 19th, 2004 at 23:33:09, Graham Said:

    I’m very interested in this, since I have to have the .php extension without fiddling…

  2. On May 27th, 2004 at 04:21:46, Walter Said:

    Hi. I?m using this on my .htaccess:

    ForceType application/x-httpd-php

    It?s working. This is the best way !?

    - Walter

Leave a Reply

Comments are moderated like crazy using a variety of plugins. There is a very high likelihood that your comment won't show up right away, especially if you have never commented here before, but it was not deleted.

Please be patient, and do not post your comment more than once. It will show up once it is approved.

You must be logged in to post a comment.