Thursday 7 August 2014

How To Integrate Wordpress Blog With Cakephp Application?


 Cakephp Wordpress Integration

Integration of blog with Cakephp application is not new for a PHP developer, but if we talk about cross platform integration, it takes time to understand functionality and compatibility of both frameworks. The same problem occurred with me last month, when client required integrating a Wodpress CMS with Cakephp Application.

I have researched a lot and find a good tutorial Integrating Wordpress with Your Website in Wordpress support section. Here is the process I followed:
  • First install WordPress and copy & paste wordpress folder into app/webroot of CakePHP.
  • Access .htaccess file from CakePHP root directory and place these lines, given below:
          RewriteEngine on
          RedirectMatch temp ^/blog/wp-admin$ http://www.example.com/blog/
          RewriteRule ^blog$ blog/ [L]
          RewriteRule ^blog/wp-admin$ blog/wp-admin/ [L]
          RewriteRule ^$ app/webroot/ [L]
          RewriteRule (.*) app/webroot/$1 [L]

This results URL like this: “http://www.example.com/blog/“, but if you want URL like this: “http://www.example.com/blog”, there should be little change in this process:
  • First install WordPress and copy & paste this folder same folder where your ‘app’ folder remained.
  • Here find CakePHP - .htaccess file to run wordpress from webroot/blog directory (Original Source: Githhub.com):
           <IfModule mod_rewrite.c>
            RewriteEngine on

            RewriteCond %{REQUEST_URI} !^/blog.*
            RewriteCond %{REQUEST_URI} !-f
            RewriteRule ^$ app/webroot/ [L]

            RewriteCond %{REQUEST_URI} !^/blog.*
            RewriteCond %{REQUEST_URI} !-d
            RewriteRule (.*) app/webroot/$1 [L]
           </IfModule>

If you have some more methods to share, please comment below.

1 comment:

  1. Thank you so much for writing this article and for sharing your code I’m sure you’ve helped many other people as well.
    Very educative post for us fresher artists….with wonderful links.
    http://www.jicstech.com/

    ReplyDelete