The following .htaccess rule replaces "OLDNAME" with "NEWNAME" in a URL and it removes the string "-2" from the end of the URL if it exists. I need to update the rule to accommodate two scenarios: "OLDNAME1" and "OLDNAME2". Both redirect to a single "NEWNAME".
RewriteRule ^(index\.php/)?OLDNAME/(.+?)(?:-2)?/?$ /NEWNAME/$2 [L,NC,R=302,NE]
I've tried several variations of the following:
RewriteRule ^(index\.php/)?(OLDNAME1|OLDNAME2)/(.+?)(?:-2)?/?$ /NEWNAME/$2 [L,NC,R=302,NE]
Any help appreciated.
You are pretty close, you can do like this:
# /nwblog => /blog
RewriteRule ^(?:index\.php/)?nwblog/(.+?)(?:-2)?/?$ /blog/$1 [L,NC,R=302,NE]
# remove /index.php/
RewriteRule ^index\.php/(.+)$ /$1 [L,NC,R=302,NE]
# remove /-2
RewriteRule ^(.+)-2/?$ /$1 [L,NC,R=302,NE]