So it happens I have a website which was started as a wordpress blog but was later developed into a cakephp site.
http://www.xyzabc.com/ – inititally a wordpress blog, now a cakephp app
http://www.xyzabc.com/blog/ – becomes the new wordpress blog’s address
How do I redirect visitors who arrive on the site through bookmarks or not-yet-updated search engine indexes so that they can land on the new wordpress blog address?
First thing you should know about CakePHP and htaccess: there are 3 htaccess files so we need to know which is the correct file to add our redirection rule.
But for this purpose, all we need to do is edit the .htaccess file in the cake app directory, the file which contains the following contents initially:
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
Since the wordpress blog has only a few posts, I added the following redirect rules at the top of the htaccess file. You might have to change the patterns depending on how your wordpress permalinks and tags were setup.
Redirect 301 /post-name-1/ /blog/post-name-1/
Redirect 301 /tag/tech/ /blog/tag/tech/
Whenever someone types in or land at http://www.xyzabc.com/post-name-1/, they will be now redirected to http://www.xyzabc.com/blog/post-name-1/