psili, that code won't work, because .* matches everything 0 or more times and /? matches a character 0 times or once... so this code of yours would match
http://www.domain.com/category/postname.html also
Code:
RewriteEngine on
RewriteRule $categories/([^/\.]+)/?^ categories/$1.html [R=301]
this would match everything except for / and . 1 or more times, so
http://www.domain.com/category/postname.html would not match...
This is not tested also, so maybe there are errors in this too
Note that the above code will work in .htacces only, to use it in httpd.conf you should add / right before the categories, like this:
Code:
RewriteEngine on
RewriteRule $/categories/([^/\.]+)/?^ /categories/$1.html [R=301]
Julio