Clean URLs with Textpattern
21 September, 22:46
After a week of tearing out my hair trying to get textpattern to display clean urls with Apache, I’ve finally cracked it!
It was hard to find an article written for server configuration noobs (like myself) so I’ll document how I managed to pull off my URL miracle right here in my lovely new blog.
Disclaimer: As mentioned above, I am not a server configuration expert – this is just how I managed it with my own set-up (textpattern 4). No guarantees folks!
Overview
- Locate .htaccess file
- Input sections into .htaccess
- Change Textpattern to clean URL mode
- Upload .htaccess to server root and cross fingers
1. Assuming your server allows the use of mod_rewrite (you can check by looking on the “diagnostics” tab under admin) Using BBEdit or some other editor, open the file called ”.htaccess” in your Textpattern installation:
2. This is the important part that I found hard to get info on (Probably not looking hard enough). Inbetween the ^ and the (.*) of the last RewriteRule insert the names of the sections you have created with Textpattern surrounded by brackets and separated by the | sign.
e.g.
RewriteRule ^(about|blog|contact|invertebrates)(.*) index.php
This is the part I missed due to being a mod_rewrite newbie.
3. Change Textpattern to use the clean URL of your choosing (admin, preferences).
4. Upload the .htaccess file to the site root folder and cross your fingers.
It should be as simple as that but my site still wouldn’t work – I kept getting 404 page not found. For some reason my configuration was looking for the pages with extra folders in the way (e.g. server/home/www/mysite then the clean url).
The answer lay in the beginning of the .htaccess file. Removing the # from the RewriteBase string and just putting / after it (RewriteBase /) pointed everything at the right place.
All I did next was to ensure all image paths were relative and Bobs your uncle, Fannys your aunt and I’m a happy monkey.
As I said at the beginning I’m no expert at this so if anyone has a simpler way to do this I’d love to know.

1056 days ago