I have recently changed how posts are categorized and changed the permalinks not to show the category. Consequently, I need to redirect the old URLs. I have tried many variations of the following but nothing seems to work:
RewriteEngine On
RewriteRule ^postname http://www.example.com/postname [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
I have also tried the following:
- instead of RewriteRule, used Redirect 301 ...
- used the full URL for the original (instead of the Regex '^')
- I have moved the redirection statement in different places i.e. inside the # BEGIN WordPress, as well as place it after the IfModule, RewriteEnging On, etc.
- I have also tried both RewriteRule and Redirect at the end of the file after # END WordPress
I have been using Chrome Incognito to test after each change to avoid the caching issues. I actually have about 40 posts that I would have to redirect to not use their old categories/sub-categories in the URL. I read somewhere that the wordpress code will redirect/rewrite to index.php so that the internal Wordpress permalinks would work but I am unsure how this interacts with the redirects that I wish to include.
I am not sure what I am missing. Any help would be greatly appreciated!