TextPress

open source content publishing system


Recipes

Apache RedirectMatch

If you used to run WordPress and imported your old blog into TextPress you now need to make sure your old URLs are still available, yet, redirected to the new ones.

If you served your old blog like:

http://blog.domain.tld/index.php/2008/01/01/my-blog-post/

The new URL will be:

http://blog.domain.tld/2008/01/01/my-blog-post

If you run apache you can make use of RedirectMatch to redirect your old URL's to the new ones.

Add to your vhost configuration the following lines:

RedirectMatch permanent ^/index.php(.*)([/]+)$ $1
RedirectMatch permanent ^/index.php(.*)$ $1

The first rule, will permanently redirect the URL's that contain the last / in the url, the second will permanently redirect those that do not contain the last /. I was unable to make that in a single rule, the redirects didn't seemed to work.

The last thing is to redirect the old uploads path to the new one:

RedirectMatch permanent ^/wp-content/uploads/(.*)/(.*)/(.*)$ /_uploads/$3

This will redirect:

http://domain.tld/wp-content/uploads/2007/05/example.uploaded.picture.png

to:

http://domain.tld/_uploads/example.uploaded.picture.png

Of course you'll have to re-upload your old blog uploads to the new one and keep the same names.