Search code examples
php.htaccesscodeigniterhttp-redirectexpressionengine

php / expression engine - redirect all URLs from one URL segment to another URL segment


I have an expression engine site that I recently redid and, while the titles of each article or page on the site did not change, the routes to them did. So, for example, where before I had:

site.com/site/code_single/name-of-page

I now have

site.com/main/code-item/name-of-page

How would I set up a redirect (either with expression engine tags or with PHP / .htaccess) so that all URLS matching site/code_single got redirected to their corresponding titles in site/main/code-item?


Solution

  • A single line of .htaccess really is the simplest solution here I think.

    RedirectMatch ^/site/code_single/(.+)$ /main/code-item/$1 [L,R=301]