Category Covered

cakephp allow sub directory by htaccess

I have two project one main project which is running fine but now i want to run another cakephp project on the same domain.


So you are in the write place this tutorial will help you to run a cakephp on a sub domain

1. First you have change the .htaccess on  /httpdocs/

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule    ^$ cake_sub_project/app/webroot/    [L]
RewriteRule    (.*) cake_sub_project/app/webroot/$1 [L]
</IfModule>

This two new line needs to add on your main .htaccess file. Here "cake_sub_project" is the sub project
RewriteRule    ^$ cake_sub_project/app/webroot/    [L]
RewriteRule    (.*) cake_sub_project/app/webroot/$1 [L]


Now goto your sub folder and make sure you have changed the .htacces on the following directory.

    cake_sub_project/
    cake_sub_project/app
    cake_sub_project/webroot

2. Need to edit the .htaccess from /httpdocs/cake_sub_project as following
   

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake_sub_project/
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

 

3. Need to edit the .htaccess from /httpdocs/cake_sub_project/app as following
   

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake_sub_project/app/
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
</IfModule>


4. Need to edit the .htaccess from /httpdocs/cake_sub_project/app/webroot as following
   

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cake_sub_project/app/webroot/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>


Write comments it works or not. Thanks :)

 

 
Comments on "cakephp allow sub directory by htaccess"
Comment by, Cristian

Thanks! it worked great!
Comment by, Prasad

Thanks It works in cakephp3.xx great..! I am bignner to cakephp can I get few sample projects.
Related posts