Clean urls are so much nicer, and I believe better spidered. Getting clean category urls the easy way (aka. the lazy way)
My site nav is hard coded into a custom form, so I changed the urls to what I want.
Which is better:
/technology/?c=css
or
/technology/c/css
Same amount of characters, but clean urls looks nicer! So how to do this with minimal effort. First I changed my custom form with the new urls. Next some ReWrite, which I was nervous being completely beginner at it
##clean category
RewriteEngine On
RewriteRule ^([A-Za-z0-9_]+)/c/([A-Za-z0-9_+]+)[/]*$ $1/?c=$2
Basically transforms new url to old form. Advantages are that it doesn’t mess up anything the way TextPattern does things. No custom hacking to make upgrade harder.
extra credit
I am also using my one plugin (because I discovered them a little later) [stw\_category_tree](http://forum.textpattern.com/viewtopic.php?id=2252 “Plugin: stw_category_tree”) to output categories for internal section nav. Thanks again santheo. So I need to change the output of that too.
<txp:stw_category_tree start="technology" onclass="li_curr" prune="true" />
[about line 63-64 change to this]
$path = ($url_mode==1) ? $pfr.$sec."/" : $path."s=".$sec."&";
return tag($cat,'a',' href="'.$path.'c/'.urlencode($cat).'"');
I could of changed to accept a paramter clean=“true”, but I am the only one using this version.
Anyway, voila clean category urls the easy way.
updated 11/29: Added a “+” sign to ReWrite rule to cover Category names with spaces
updated 11/30: Added missing line from altering stw\_category_tree