2
votes

I've been trying to setup CakePHP on a development section of my server and I can't seem to solve the "URL rewriting is not properly configured on your server" error. I suspect I'm not configuring the .htaccess files with the correct RewriteBase. I've tried a wide variety of different RewriteBase for each file, but I can't seem to hit the right ones, and Cake doesn't give me any information other than "not working" (URL rewrite errors don't end up in Cake's error log).

I do not have access to my httpd.conf file, but I've used .htaccess and mod_rewrite with other frameworks (Wordpress and CodeIgniter) without a problem.

My base url for the site is: http://dev.domain.com/cake/

My base server path is: /home/username/public_html/dev/cake/

Cake root .htaccess:

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

Cake app directory .htaccess:

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

Cake webroot directory .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /cake/app/webroot
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
4
Now I'm confused. If I get rid of the RewriteBase in each of the files, then add to the URL (say, dev.domain.com/cake/stuff), I get an error message saying I haven't created that controller, and if I create the controller it seems to work. So is URL rewriting working, but Cake's check failing?Azuaron
I was also getting an error because PDO wasn't installed on my server. Upon solving that error (php.ini issue), the URL rewrite error disappeared. So the URL rewrite error might not have anything to do with URL rewriting, and could be cause by a (seemingly) separate issue.Azuaron

4 Answers

6
votes

Did you create a new default.ctp layout file and then "URL rewriting is not properly configured on your server." appeared?

If that is the case, it happened to me. It's working just fine. I think Cake is throwing a bad error message here.

5
votes

Problem is with CSS. If U don't make page on default layout of cake, and in your new layout You dont have default css: cake.generic.css it will show this error on page home.ctp. Look in code of home.ctp (View/Pages) and look - the id="url-rewriting-warning" of <p> where this error message is have in cake.generic.css value of display:none.

0
votes

What does your vhost.conf look like? If you have a proper path in DocumentRoot, you shouldn't need to specify RewriteBase in .htaccess at all. Just stick with the defaults.

Try DocumentRoot /home/username/public_html/dev/cake/app in vhost, and remove RewriteBases from your .htaccess.

0
votes

The problem for me was the css issue mentioned in another answer.

If you changed the css file in the default layout, you might need to add the following lines to your new css file:

#url-rewriting-warning {
    display:none;
}

... as long as rewriting appears to be working in all other ways.