0

I've been running cakephp on localhost and finally uploaded to my server. I didn't have to touch the index.php files (using XAMPP) and it ran perfectly but now that I'm ready to go live I'm having some issues.

When I typed www.mydomain.com it loaded www.mydomain.com/users/index but it gave a 404. Am I correct to assume it's finding my controllers because it's displaying /users/index (one of my controllers and an action in it)? I checked and all of my controllers, models, and views are on the server so I'm not sure why it's having trouble. Could this be an issue with my index.php file, or is it something directly related to cake?

Also, where can I change the settings so my site will launch by default to www.domain.com/posts? Through routings I can then make www.domain.com/posts to www.domain.com, right?

I watched this video I watched this video http://www.youtube.com/watch?v=4GobWo1rIkE (I'm using cake 2.x not 1.x) and I can't get it to work properly.

edit - I got it to find the views, but my css file isn't loading

user1104854
  • 2,137
  • 12
  • 51
  • 74

2 Answers2

0

Do you have mod_rewrite installed/configured on the server?

Also, where can I change the settings so my site will launch by default to www.domain.com/posts? Through routings I can then make www.domain.com/posts to www.domain.com, right?

Correct. Through the router.

mittmemo
  • 2,062
  • 3
  • 20
  • 27
0

Based on the behaviour you are reporting, it sounds like URL Rewriting is either not enabled, or not configured correctly.

URL rewriting allows for the webserver to correctly locate resources and assets such as CSS.

This can be solved in a number of ways.

The recommended way is to setup the server to use the app/webroot directory as your document root. This directory contains an index.php file which operates as the front controller for your application, and assets will be found without issues. Using this directory for your document root also means that the rest of your code outside of the webroot is secure.

Once that is done, ensure that your URL rewriting is enabled and setup correctly.

If you're using Apache, you need to have mod_rewrite enabled, and you need a .htaccess file in your app/webroot directory.

Often when people FTP the contents of their application across to a server, the .htaccess files are skipped as they are considered hidden files on most operating systesm. Double check that the .htaccess file is in place, and that rewriting is enabled.

Default Route

If you want the default URL / to go to the PostsController, you can modify the default route in app/Config/routes.php:

Router::Connect('/', array('controller' => 'posts', 'action' => 'index'));
Community
  • 1
  • 1
Predominant
  • 1,460
  • 12
  • 24