: Htaccess Rewrite Syntax? 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
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?
More posts by @Jessie594
1 Comments
Sorted by latest first Latest Oldest Best
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)$ [L,R=301]
P.S.
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.