Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
962 views
in Technique[技术] by (71.8m points)

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

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 in the root...). The .htaccess-files (0) - (3) are according to this post [SO]:, and as this is a CakePHP&Wordpress server, I tried this advice here, too [SO]. The app is obviously located in the CAKEAPP-Folder, where a subdomain cakeapp.mydomain.com points at.

ROOT
├── .htaccess (0)
├── CAKEAPP
│?  ├── .htaccess (1)
│?  ├── app
│?  │   ├── .htaccess (2)
│?  │?  ├── WEBROOT
│?  │?  │   ├── .htaccess (3)
├──{wordpress-files}

(0) .htaccess in the ROOT FOLDER

    Action php /cgi-php52/php
AddHandler php52 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

php_value memory_limit "128M"

#BEGIN Image Upload HTTP Error Fix
<IfModule mod_security.c>
<Files async-upload.php>


</Files>
</IfModule>
<IfModule security_module>
<Files async-upload.php>


</Files>
</IfModule>
<IfModule security2_module>
<Files async-upload.php>


</Files>
</IfModule>
#END Image Upload HTTP Error Fix

(1) .htaccess in the CAKEAPP-Folder

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

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

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...