Cannot get 301 redirection in htaccess to work (either Redirect or Rewrite)

The ^ in your rewriterule means the URL must begin with the postname, as in your new structure – so what you’re saying in that second line is, “redirect http://www.example.com/postname to http://www.example.com/postname“.

So it’s the ^ that’s throwing things off.

If you were previously using URLs like http://www.example.com/categoryname/postname/ then I would suggest instead:

RewriteEngine On
RewriteRule ^categoryname/(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^categoryname2/(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^categoryname3/(.*)$ http://www.example.com/$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Just add a RewriteRule on its own line for every category. The “$” tells the server to save everything that comes after the category name (i.e. your post slug) and redirect to example.com/that-particular-slug.