Every since an upgrade to WordPress 3.3 URLs are not redirecting as they should.
Changed: domain.com/2010/10/postname/ to: domain.com/postname/
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/[0-9]{4}/[0-9]{2}/(.+)$ /$1 [NC,R=301,L]
The problem was due to the leading slash and not using $3
There’s a script here you can use to generate .htaccess rules if you want to change permalinks to the /%postname%/ structure.
http://yoast.com/change-wordpress-permalink-structure/
My permalinks were exactly the same as yours, I used this tool to change them and it is working well.
The last rule will never get applied if the previous rule matches. Assuming that the http://domain.com/2010/10/postname/ request doesn’t match a file or directory, the
RewriteRule . /index.php [L]
is going to rewrite the URI to/index.php
thus it’ll never get to your rule. Try moving your rule up to the top, just belowRewriteBase /
, and duplicate the !-f/!-d conditions, so that it looks like this:Also, if this is in an .htaccess file, you need to remove the leading slash in the rule match so that it looks like this:
^[0-9]{4}/[0-9]{2}/(.+)$