CakePHP 1.3.2 .htaccess not covering up the index.php

I’m unable to run an old CakePHP application (version 1.3.2) on a new server and I narrowed down the problem to the .htaccess file.

Let me first describe the folder structure on the server:

public_html
- cake
- a_bunch_of_other_domain_name_folders
- .htaccess [1] //using [1] as naming convention here
- old_domain_name.com
--- application_files
--- .htaccess [2]
--- webroot
----- .htaccess[3]
----- index.php

.htaccess [1] file has a bunch of rewrite rules for the other domains but nothing for the one in question.

.htaccess [2] has the following code, comments are intentional as they actually crash the application, explanation follows below:

Options -Indexes

AddDefaultCharset utf-8
#DefaultLanguage bg
ServerSignature Off

#<IfModule mod_rewrite.c>
#        RewriteEngine on
#       RewriteBase /
#       RewriteCond %{REQUEST_URI} !webroot
#        RewriteRule    ^$    webroot/    [L]
#        RewriteRule    (.*) webroot/$1    [L]
#</IfModule>

.htaccess [3] is as follows, although I don’t think I actually get to it:

Options -Indexes
AddDefaultCharset utf-8
ServerSignature Off
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

And really quickly, my current routes.php, just in case it might help:

# Extensions
Router::parseExtensions('html', 'rss', 'pdf', 'xls');

# Root
Router::connect(
    '/',
    array(
        'language' => __('cl', true),
        'controller' => 'pages',
        'action' => 'display',
        'slug' => __('home', true)
    )
);

So what happens currently, with the comments in the .htaccess [2], is that the home page of the web site successfully loads with the url just being NEW_DOMAIN.com (note: not old_domain which is the name of the folder).

However, as soon as I click on a link I get redirected to a page which is NEW_DOMAIN.com/controller/view/ which displays a blank page with no error messages. If I manually fix the URL to NEW_DOMAIN.com/index.php/controller/view/ then it starts to work.

And finally, if I go in .htaccess [2] and uncomment the rewrite rules there, as soon as I try to load even the home page, I get 500 Internal Server Error and all dies right there.

I don’t have much knowledge regarding .htaccess files so I’m not sure how to approach debugging this. I tried removing the RewriteBase and/or the RewriteCond parts in .htaccess [2] but the results are the same. Is the problem there or should I alter the .htaccess [1] file? Any tips would be highly appreciated.


Source: apache

Leave a Reply