If you have a website or blog that was first developed in WordPress and then if you decided to convert it into some other platforms like cakephp, joomla, drupal website or else. Then you may want to install wordpress again in blog folder. Then the structure of your website will be like this
http://www.abc.com/ – inititally a wordpress blog, now a cakephp app
http://www.abc.com/blog/ – becomes the new wordpress blog’s address
Now the issue comes here is
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?
CakePHP’s htaccess
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:
RewriteBase /
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/
Final Result
Whenever someone types in or land at http://www.abc.com/post-name-1/, they will be now redirected to http://www.abc.com/blog/post-name-1/
I know this is not a robust and great solution but if you have Sitemap of all your blog posts then you can do the above trick very easily.
See my blog sitemap here www.vaseemansari.com/blog/sitemap.xml and you can see the url of all blog posts, now you need to copy the url and change it in .htaccess file and you are done with the trick. Have fun and feel free to ask me if you have any confusions in mind regarding the above tutorial of htaccess.
Thanks
24 replies on “CakePHP Tutorial: htaccess Redirecion Rules and modrewrite Tips”
[…] How to redirect all old wordpress url to new website or wordpress blog using htaccess – CakePH… […]
[…] How to redirect all old wordpress url to new website or wordpress blog using htaccess – CakePH… […]
Hi! Sweet article..! I really liked you’r site. Keep going.
I’m currently blogging for a (poor) living for someone else… but I like it. You’ve inspired me to keep doing it, and look to doing it for myself soon
Thanks for the useful post! I would not have found this myself!
I’ve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.
How do you make your blog site look this good! Email me if you can and share your wisdom. I¡¯d be thankful.
Hello.This post was extremely interesting, especially because I was searching for thoughts on this issue last Sunday.
Hello my friend! I wish to say that this post is amazing, nice written and include almost all significant infos. I’d like to see more posts like this .
Tell your readers when, and what determined you to make a blog.
Hi blog owner, listen, do you have facebook profile or fan page? I was looking for one on facebook but did not discover one.I would really like to become a fan!
Hey very nice website!! Man .. Beautiful .. Amazing .. I’ll bookmark your web site and take the feeds also¡I’m happy to find a lot of useful information here in the post, we need develop more strategies in this regard, thanks for sharing. . . . . .
Title…
Sony Introduces new PSP2 Console Mobile…
Would you be interested in exchanging links?
Oh my goodness! a tremendous article dude. Thank you Nonetheless I am experiencing difficulty with ur rss . Don’t know why Unable to subscribe to it. Is there anybody getting identical rss problem? Anybody who knows kindly respond. Thnkx
You can subscribe to my rss feed at http://feedburner.google.com/fb/a/mailverify?uri=VaseemAnsari
and you can view my blog rss feed at http://feeds2.feedburner.com/vaseemansari
Very interesting entry, I look forward to the next!
Love the blog here. Nice colors. I am definitely staying tuned to this one. Hope to see more.
I’ve been searching in google for some home and garden ideas and accidentally found this http://www.vaseemansari.com website.
It was a helpful experience for me to go through this webpage. It definitely stretches the limits with the mind when you learn useful info and make an effort to interpret it properly. I am going to glance up this web site oftentimes on my PC. Thanks for sharing
I’m glad that I’ve found your http://www.vaseemansari.com web site.
Nice post! i love it, please bookmark this page in digg or mixx because I can find it easily. Great article:) thanks for sharing this information. You guys do a great website
Thank you very much for your post! I am very interested in your points.
Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but other than that, this is great blog. An excellent read. I will definitely be back.
Some great fresh informations here. This gives me hope that there are others out there doing the same things I am trying to do.
Another possibility would be to use the cakephp-internal routes facilities. One could for example create a Controller responsible for redirection and route every blog entry’s permalink to it. This gives you a little more flexibility in case you want to programmatically influence the redirection.