Free Android CakePHP GMaps Articles by Bali Web Design

August 2, 2010

How to redirect /app/webroot/blog/ into /blog/ WordPress Cakephp

Filed under: cakephp,php,wordpress — admin @ 8:16 pm

At this time, a company website normally should have blog to post some business activity or related activity with website themes. WordPress is the best blog framework (CMS) that i ever used. When i was build web application under my own php framework, i wasn’t worried about integrating wordpress into my website. It would has separated setting with main application.

However, now i am using cakephp framework. And if we need to put file or folder, it need to be put inside app/webroot folder. So if i need to install wordpress blog in, i need to put the blog folder inside /app/webroot/.

The problem is about the url, with standard setting the blog would be redirected to not to This is not look good for visitor and also for seo. Because the folder structure is to deep.

After researching, i play with .htaccess setting to redirect /app/webroot/blog/ into /blog/ url. And the solution is very simple. So this is the step how i install wordpress blog inside cakephp framework.

  1. upload wordpress files into /app/webroot/blog/ folder on server
  2. setting /app/webroot/blog/wp-config.php with appropriate setting for database
  3. and then install wordpress. On this step you will get directed to Dont worried about the path, we can fix it easily
  4. After installation finished, go to wordpress admin area at and then log in
  5. Go to Settings > General. Change WordPress address (URL) and Site address (URL) into and then Save.
  6. If using mod_rewrite for wordpress, Open /app/webroot/blog/.htaccess. Change into
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /app/webroot/blog/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /app/webroot/blog/index.php [L]
  7. Open /.htaccess, Change its setting into
    RedirectMatch temp ^/blog/wp-admin$
    RewriteRule blog$ /blog/ [L]
    RewriteRule blog/wp-admin$ /blog/wp-admin/ [L]
    RewriteRule ^$ app/webroot/ [L]
    RewriteRule (.*) app/webroot/$1 [L]
  8. Finished. Now you will have wordpress blog url at

I notice that this setting also fix the problem user access without end /, and redirected into

So that is how we can redirecting into for installing WordPress blog inside Cakephp Framework


  1. if you put your blog in document root you can use:

    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]

    Comment by michas — August 3, 2010 @ 2:26 pm

  2. @michas: thank you michas, you solved another problem for installing wordpress at document root which cakephp installed there

    Comment by admin — August 3, 2010 @ 7:47 pm

  3. This tutorial is absolutely right but there have a little mistake
    when you going to install wordpress try this
    this line content a little mistake
    3. and then install wordpress. On this step you will get directed to Dont worried about the path, we can fix it easily.

    this line is mistake free.
    3. and then install wordpress. On this step you will get directed to Dont worried about the path, we can fix it easily.

    Comment by Sourav Mondal — November 19, 2010 @ 5:38 am

  4. @Sourav Mondal: thank you, you are right

    Comment by admin — November 19, 2010 @ 5:46 am

  5. i changed settings from wp-admin as you said.. i opened front-end perfectly but it changed my admin password.. i tried it many times every time this problem ruined my way..
    can you tell me what is it problem?

    Comment by Tahir — June 1, 2012 @ 5:12 am

  6. This was REALLY helpful! I couldn’t figure out why it kept adding the extra directories for the blog. It did, though, take me a second to figure out where the /.htaccess file was, since I wasn’t entirely sure if the root was the /app directory, or the one before. For anyone wondering, it’s the /html directory in CakePHP, or at least the one I have.
    Thanks again for the help.

    Comment by Joseph — March 20, 2013 @ 3:31 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment