mindgarden

.mindgarden is the digital playground of marc tobias kunisch

.opinions on this website are in not necessarily those of my employer

.send an email to info 'at' mindgarden 'dot' de

.follow the mindgarden on twitter @mindgarden_de or @tobestobs
.occasional guest bloggers are @lwsrc, @dheeva and @idrathernot

14.09.2009

Rewriting textpattern URLs to habari URLs

So I recently moved this website onto a new server swapping Textpattern for Habari

The biggest road block that I had to deal with was keeping my old crappy textpattern URLs that I had never changed to nice URLs functional. Which sounds easy enough using some regular expressions to do some mod_rewriting in the .htaccess file (if that in itself sounds easy to you).

The URLs that I was using with textpattern and that are now indexed by google are as follows:

http://www.mindgarden.de/index.php?id=123

which had to redirect to something like

http://www.mindgarden.de/?id=123

The problem being that habari does some heavy rewriting in the .htaccess itself. The guys in the habari IRC channel were incredibly helpful and helped me figure it out. So in case someone out there tries to do what I did, here’s what worked for me in the end:

RewriteCond %{THE_REQUEST} ^w+ /index.php?id=(d+)
RewriteRule ^(.*)$ /?id=%1 [R=301,L]

 1