2016-04-16

I run a bunch of websites on OpenBSD. One of them is running WordPress for a local group. When I upgraded the server from OpenBSD 5.7 to 5.8 last year, I finally switched from the version of Apache 1.3 that used to come in the base install, to the new relayd-based httpd that had been in the works. Without mod_rewrite, I disabled the so-called "pretty" permalinks with useful titles, going back to the old numbered-posts setup.

This had been bothering me last weekend, and earlier this week, I saw someone else with the same problem. I had written a totally custom CMS for one of my other websites, and it also uses an awkward set of front-controllers written in PHP in order to make friendly-looking URLs. I decided to explore my method of setting that site up, applied to WordPress.

You have the option of using so-called "PATHINFO" Permalink URLs in WordPress. Those might look like:
http://blog.bar.com/index.php/2016/hello-world/

That's getting there. I opted to make my site more like:
http://blog.foo.com/posts/2016/04/hello-world/

I started by creating a symbolic link called "posts" pointed to index.php.

ln -s index.php posts

Since I'm using PHP-FPM, I had to also make sure that FPM would acknowledge this new file since it lacks the .php extension. Beware the rule of unintended consequences here. You'll want an airtight httpd.conf when it comes to what things it decided to toss over to the PHP-FPM socket. Blank out the security.limit_extensions variable in /etc/php-fpm.conf

security.limit_extensions =

Next, adjust your httpd.conf to send stuff destined to the /posts URI (note the * at the end, it's important!) to PHP-FPM. All of my sites are under /var/www/sites/ (including the one I'm setting up WordPress on). My httpd.conf clause for this site looks kind of like this:

HiR Featured Columns

HiR Tools

HiR Categories

About HiR

HiR is what happens when 1990s-era e-Zine writers decide to form a blog. Most of us hail from the Great Plains region of the United States.

Ax0n, HiR founder and editor-in-chief is an information security specialist currently working in the luxury goods industry.

Asmodian X joined HiR in December 1997 and currently works as a web developer and SysAdmin in the education industry.

Frogman has been on board since May 1998 and has many technical passions. When not experimenting with obscure hardware, he can be found leaping from one rooftop to the next, making the world his office.

TMiB has also been helping since 1998. Also our resident Physicist and go-to guy for xkcd jokes we don't get, The Man in Black currently works in the Internet industry in an east-coast data center.