Mobile app version of vmapp.org
Login or Join
Jessie594

: 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

@Jessie594

Posted in: #Htaccess #ModRewrite

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Jessie594

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gloria169

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme