Having trouble configuring CakePhp on an Apache server. It worked fine in my dev environment, and now I’m looking to deploy.
The url will look like:
"http://www.example.com/mysite/"
A sample controller action would be:
"http://www.example.com/mysite/users/login"
Using the default htaccess files doesn’t seem to work.
mod_rewrite is loaded according to phpInfo, and it is rewriting urls, but it sees /mysite/ as a controller.
Here is the output and my .htaccess files
Missing Controller
Error: MysiteController could not be found.
Error: Create the class MysiteController below in file: >app/Controller/MysiteController.php
root:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
app:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
webroot:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
Should I be looking to change my .htaccess files, or my CakePhp config file? I’ve tried a few different RewriteBases, only managed to get different errors.
Edit: The server is running php-cgi and it appears all of my links are being written to a cgi-bin. For example:
$this->Html->meta('icon');
writes the path “/cgi-bin/cgiwrap/w3u_mysite/mysite/favicon.ico”
Any idea as to where or why this could be happening?
As suspected in my edit, the problem was related to the server running cgi php. I’m not exactly sure what the issue was, but the CakePhp google group provided this solution:
In app/Config/core.php there is a commented out definition for App.baseUrl. Uncomment it and replace with the following
Above it, there are comments saying to remove the .htaccess files that you should ignore. The site worked fine with the .htaccess files as their standard values, no RewriteBase needed. The one annoyance was that
$this->Html->css()and$this->Html->js()functions did not work, but I only call them in templates, so it’s not terrible to hard code them.If anyone has insight into the cause of these cgi woes, please share. It still feels a bit like a kludge if I can’t use all of the Html helpers.