0

Switching from ExpressionEngine to Wordpress and need to set up redirects in htaccess.

The paths to the articles will change from mysite.com/section/read/article-name to mysite.com/article-name/. The section part of the path has six variants.

Unsure whether to look at redirectmatch or rewrite rule being a toatl novice with htaccess.

Thanks

2 Answers2

0

Either would work, so I'll use RedirectMatch. To be specific about the section name, it would be:

RedirectMatch 301 "/(?:section|another-section|third-section)/read/(.+)$" /$1

Replacing your section names in there, separated by pipes.

Or for anything in a directory called read in a top level directory:

RedirectMatch 301 "/[^/]+/read/(.+)$" /$1
0

Since it is a one to one mapping and just the final part to be preserved, you don't need RedirectMatch. Redirect is sufficient

Redirect /section/read /

When it works as expected, you may set the status code to 301.

Redirect 301 /section/read /

If you want to use mod_rewrite instead, this would be

RewriteRule ^section/read/(.*)$ /$1 [R,L]

When everything works as it should, you may replace R with R=301. Never test with R=301.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198