I need to run CakePHP 2.1 application in an environment with CGI-PHP and without the ability to declare apache aliases. I want to redirect requests to the CakePHP subdomain using mod_rewrite, but this will not work.
Current setting
- Webroot
~/user/public_html - CakePHP is located in
~/user/public_html/cakephp/ - CakePHP should be requested in
dev.mydomain.tld
What I have so far (all the ways regarding webroot):
~/user/public_html/.htaccess
RewriteEngine on Options +FollowSymlinks RewriteCond %{HTTP_HOST} ^(www\.)?dev\.mydomain.com$ [NC] RewriteCond %{REQUEST_URI} !^/cakephp/app/webroot/ [NC] RewriteCond %{REQUEST_URI} !/$ RewriteCond %{DOCUMENT_ROOT}/cakephp/app/webroot%{REQUEST_URI}/ -d RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R,L] RewriteCond %{HTTP_HOST} ^(www\.)?dev\.mydomain.com$ [NC] RewriteCond %{REQUEST_URI} !^/cakephp/app/webroot/ [NC] RewriteRule ^(.*)$ /cakephp/app/webroot/$1 [L]
~/user/public_html/cakephp/app/webroot/.htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L]
Problem
Requests are somehow incorrectly routed (the application works without problems in my development environment with PHP as a module and virtual host at the level of /cakephp/app/webroot/ ). When I request the homepage in dev.mydomain.tld , I get an error message, Cake tells me that CakephpController is missing.
Debug information
interesting parts of $_SERVER debugged as the first line in /cakephp/app/webroot/index.php
[REDIRECT_REDIRECT_REDIRECT_STATUS] => 200 [REDIRECT_REDIRECT_STATUS] => 200 [REDIRECT_HANDLER] => php-script [REDIRECT_STATUS] => On [HTTP_HOST] => dev.mydomain.tld [HTTP_CONNECTION] => keep-alive [SERVER_SOFTWARE] => Apache/2.2.21 (Unix) [SERVER_NAME] => dev.mydomain.tld [SERVER_ADDR] => 192.0.43.10 [SERVER_PORT] => 80 [DOCUMENT_ROOT] => /home/user/public_html [SCRIPT_FILENAME] => /home/user/public_html/cakephp/app/webroot/index.php [REDIRECT_URL] => /cakephp/app/webroot/index.php [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => / [SCRIPT_NAME] => /cakephp/app/webroot/index.php [_PHP5_WORK_DIR] => /home/user/public_html/cakephp/app/webroot [PHP_SELF] => / [ORIG_PATH_INFO] => [ORIG_PATH_TRANSLATED] => /home/user/public_html/cakephp/app/webroot/index.php [PATH_INFO] => /cakephp/app/webroot/index.php
interesting parts of the CakeRequest object are CakeRequest to the dispatcher:
url => 'cakephp/app/webroot/index.php' base => '/cakephp' webroot => '/app/webroot/' here => '/cakephp/cakephp/app/webroot/index.php'
Question
So, what I donβt understand is why the CakeRequest object has links to my folder structure, and $_SERVER['REQUEST_URI'] == '/' . What did I have to do to get it right? And first of all, where should I look for the problem: in the mod_rewrite directives or in CakePHP? I tried some things, including setting RewriteBase in .htaccess files and different settings for App.baseUrl in the Configuration object, but nothing helped here.
I would be very grateful if anyone could give me a pointer on how to solve this problem.
bfncs source share