.htaccess / mod_rewrite.c : CakePHP application in a subfolder where the root folder hosts a Wordpress installation

前端 未结 2 1266
悲&欢浪女
悲&欢浪女 2021-01-20 21:28

I\'d like to deploy my CakePHP-app from localhost to the webserver, but I get Error 500.

My Folder structure looks like this (note: the Cake-app is not

相关标签:
2条回答
  • 2021-01-20 21:39

    The following works for mydomain.com/cakeapp:

    (0) .htaccess in ROOT FOLDER

    #Action php /cgi-php52/php
    #AddHandler php52 .php
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteBase /
     RewriteRule ^cakeapp/(.*)$ /cakeapp/$1 [L,QSA]
     RewriteRule ^index\.php$ - [L]
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    

    (1) .htaccess in the CAKEAPP-Folder

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

    (2) .htaccess in the ROOT/CAKEAPP/APP-Folder

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

    (3) .htaccess in the ROOT/CAKEAPP/APP/WEBROOT-Folder

    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteBase /cakeapp
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
    
    0 讨论(0)
  • 2021-01-20 21:57

    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/
      
      RewriteEngine on
      RewriteBase /
      RewriteRule    ^$ cake_sub_project/app/webroot/    [L]
      RewriteRule    (.*) cake_sub_project/app/webroot/$1 [L]
      
      
      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

    RewriteEngine on RewriteBase /cake_sub_project/ RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L]

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

         
      
      RewriteEngine on
      RewriteBase /cake_sub_project/app/
      RewriteRule    ^$    webroot/    [L]
      RewriteRule    (.*) webroot/$1    [L]
      
      
    2. Need to edit the .htaccess from /httpdocs/cake_sub_project/app/webroot as following

         
      
      RewriteEngine On
      RewriteBase /cake_sub_project/app/webroot/
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
      
      
    0 讨论(0)
提交回复
热议问题