# 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]
RewriteRule ^foo$ /bar [L,R=301]
</IfModule>
# END WordPress
Those lines are working for wordpress but RewriteRule ^foo$ /bar [L,R=301]
is not redirecting when I open www.example.com/foo
Order of RewriteRule matters in .htaccess. Change your .htaccess code to this:
Have you tried putting that specific rule just below the
RewriteBase /
rule? I think the other rules are already doing stuff causing your last one to be ignored.