Question

My cakephp is not loading any css,js. i uncommented the line Configure::write('App.baseUrl',env('SCRIPT_NAME')); in core.php. and now get all the css and js but I get missing controllers. I have to put index.php in the url. eg:-http://localhost/myapp/index.php/login i enabled the mod_rewrite but still its not working

Was it helpful?

Solution

If you are NOT using mod_rewrite, then you must:

A. Uncomment Configure::write('App.baseUrl', env('SCRIPT_NAME')); (which you said you've done)

B. Remove or disable your 3 .htaccess files (you haven't mentioned doing this...)

/.htaccess

/app/.htaccess

/app/webroot/.htaccess

Don't delete the files, just rename them to eg. .htaccessXXX so you can easily re-enable them later. Also remember .htaccess are hidden files - so Google "how to show hidden files" if you can't already see them in your file browser.

C. You must include index.php in all your URLs. Eg. http://www.example.com/index.php/my_controller/my_action

Did you remember to do step 2 - disable your .htaccess files?

And remember that if you want to re-enable mod_rewrite again, then you must undo ALL the above three things, ie, comment out Configure::write('App.baseUrl', env('SCRIPT_NAME'));, enable all 3 .htaccess files, and no longer include /index.php in your URLs.

But the biggest question here is, are you really using Cakephp 1.2? This question has been tagged CakePHP 1.2 - but Version 2.1 is out now, so you should probably be using that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top