i’m using MAMP on my MacBook Pro as a local server. PHP and MySql are running fine. However, i have a strange issue with CakePHP – CSS only works on homepage of my site and only by the two following paths:
‘localhost’ and ‘localhost/index.php’
Using ‘localhost/index.php/’ however returns just the bare unstyled markup as does all other pages in the site. How can a slash a the end break the CSS?
A few searches have suggested this could possibly be a mod rewrite issue in apache, but i’m out of my depth to be honest – i don’t know how to test if changes i make turn mod rewrite on.
As CSS works only for 2 specific paths, could it perhaps be a problems with my routes? I only have 2 defined – ‘/’ and ‘/index.php/’ – and they are both the same.
Any help will be greatly appreciated,
James
The problem is most likely as tbwcf says that you’re trying to load the CSS files using relative file paths, but you should always use CakePHP’s helpers to add resource files to the layout:
The above will output
The benefit is that if you install the app to some other directory the path changes automatically:
Do not use relative file paths like
../css. It will break the layout again in all but the simplest cases.