I have a bunch of files with a "NEW-" prefix (e.g. "NEW-index.php"). I need to do a 301 redirect to the corresponding file without the prefix. I've tried a few things but I'm not getting the regex syntax correct. Can anyone show me the right way to do this?
This does work fine here:
# Some options that _may_ be required for rewrite to work # (depends on hosting/server configuration) Options +FollowSymLinks +SymLinksIfOwnerMatch -MultiViews # Activate Rewrite Engine RewriteEngine On RewriteBase / # actual rewrite rule RewriteRule ^(.*)NEW-(.+\.php)$ $1$2 [L,R=301]
I suggest using
302 code for testing, and if everything works fine -- only then change to required
301. The reason -- modern browsers do cache such 301 redirects, so you may have brand new rule (or no rule at all) but you still will see the same redirect. In such case -- clear browser cache and restart it .. or try it in another browser.