Thursday, June 28, 2012

CakePhp 2.0: images, styles all break when installing in web server root

I've had a cake 2.0 install running for some time on my hosted web server. I installed it in /test/cakephp. All was well. I didn't have to use .htaccess or anything. And I haven't messed with APP_DIR, ROOT or WEBROOT_DIR.

When using an Html->Image tage my images would have the path:

/test/cakephp/img/logo.png

Internally Cake did the "magic" that transforms "img" to "/test/cakephp/app/webroot/img", where it is physically located.

Now I've put my Cake install in the root of my webserver (/html) and my images and styles are all broken.

I am using all of the default Cake directory names - app, lib, plugins and vendors, and they are all in the web server root dir.

The page itself loads, so it seems the index.php in the root is working, it finds Cake, etc. But my images now have the path:

/img/logo.png

... and the "magic" has died. My server now seems to be looking for the images physically in /img, but of course they are actually in /app/webroot/img.

How can I fix this? I tried copying the default .htaccess, the one that comes with the Cake download, but my server chokes on it. Apparently I can't use .htaccess. I don't see any reference to mod_rewrite in phpinfo() so I gues my provider doesn't support it.

Ideally I would like to get this to work without using .htaccess or changing the DocumentRoot in my apache config. What I don't get is, in the index.php it says:

This file collects requests if: - no mod_rewrite is available or .htaccess files are not supported

Well, this seems to be my case. Is there anything special I need to do to get this working?

Any help?

Thanks!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: