Sam Brown

Clean URLs in Textpattern

I hear a lot of people are having problems using Clean URLs in Textpattern, and I myself keep running into the same problem everytime I reinstall the software to use. These are the steps I take to get them to work.

My .htaccess file:

  1. RewriteEngine On
  2. RewriteRule ^(about|article|archive)(.*)$ /index.php?s=$1&rwtxpp=$2 [PT,QSA]
  3. Download this code: /code/cleanurls_htaccess.txt

Of course you will have to change the section names to match yours.

My index.php file:

  1. <?php
  2. if (!empty($_GET['rwtxpp'])) $_SERVER['PATH_INFO'] = $_GET['rwtxpp'];
  3. include "./textpattern/config.php";
  4. include $txpcfg['txpath']."/publish.php";
  5. textpattern();
  6. include($_SERVER["DOCUMENT_ROOT"]."/shortstat/inc.stats.php")
  7. ?>
  8. Download this code: /code/cleanurls_phpcode.txt

You should continue to create the sections files that TXP asks you to make when you make a new section, but when it asks for you to add those lines to the .htaccess file, simply add the name of your section into the .htaccess file (as shown above) inbetween the brackets.

Post a link to this on Twitter ↩

Comments

There currently aren't any comments on this post, leave the first?

Commenting has closed for this article. Feel free to me.

Sam Brown co-founded Iterate, and was previously VP of Design at Foursquare. Based in NYC.

DribbbleEndorseFacebookFoursquareInstagramTwitter