Seo Redirect in WordPress Using Regular Expressions in .htaccess

We just had a client who wanted to redirect old pages leading to custom post types to new links, using the same slug.

In our case, we wanted “” to be redirected to “”.

Of course we’ll be using regular expressions and after a bunch of trials, we get it to work.

The line that does the magic is “RewriteRule groups/(.*)$1 [R=301,L]”.

See an example of a .htaccess file below:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteRule groups/(.*)$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

129 Newbury Street, Suite 400
Boston, MA 02116