.htaccess rules to have wordpress in root and cakephp in subfolder

Solution:1

Location: public_html/.htaccess

# ===============================
# WordPress Root Configuration
# ===============================

RewriteEngine On
RewriteBase /

# Exclude CakePHP from WordPress
RewriteRule ^cake(/.*)?$ – [L]

# WordPress front controller
RewriteRule ^index\.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

# ===============================

Location: public_html/cake/.htaccess

# ===============================
# CakePHP Subdirectory Router
# ===============================

RewriteEngine On
RewriteBase /cake

# Forward all requests to app/webroot
RewriteRule ^$ app/webroot/ [L]
RewriteRule ^(.*)$ app/webroot/$1 [L]

# ===============================

Location: public_html/cake/app/.htaccess

# ===============================
# CakePHP App Layer
# ===============================

RewriteEngine On
RewriteBase /cake

RewriteRule ^$ webroot/ [L]
RewriteRule ^(.*)$ webroot/$1 [L]

# ===============================

Location: public_html/cake/app/webroot/.htaccess

# ===============================
# CakePHP Front Controller
# ===============================

RewriteEngine On
RewriteBase /cake

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

# ===============================

Solution:2

# ===============================
# WordPress with CakePHP Exclusion
# ===============================
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Do NOT route CakePHP URLs to WordPress
RewriteCond %{REQUEST_URI} ^/cake(/|$)
RewriteRule ^ – [L]

# WordPress front controller
RewriteRule ^index\.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
# ===============================