... except in my setup. I have installed CakePHP into a subdirectory of my development root. This seems to confound CakePHP - which is possibly due to some Apache settings.
I have my development in a subdirectory of my home:
/home/raymond/dev/workspace. My Apache configuration sets this as the root for http://localhost/dev/:
Alias /dev "/home/raymond/dev/workspace
<Directory "/home/raymond/dev/workspace">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I use Eclipse, so this seems to make sense. This means I can have
/home/raymond/dev/workspace/birthclassfor the birthclass site development, and now:
/home/raymond/dev/workspace/cakephpfor the CakePHP experiment. All fairly logical so far ...
... when having followed a tutorial, all I get from Apache is:
The requested URL /home/raymond/dev/workspace/cakephp/app/webroot/ was not found on this server.
After some monkeying around, I have found the trick: edit the .htaccess files. There are three: in the CakePHP root, app and app/webroot. In each case, the RewriteBase must be defined. In my case, these are /dev/cakephp/, /dev/cakephp/app/ and /dev/cakephp/app/webroot/ respectively. So now, my cakephp/app/webroot/.htaccess file look like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dev/cakephp/app/webroot/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
And now I have a fully functioning CakePHP setup in its own subdirectory. When I request http://localhost/dev/cakephp, I get my CakePHP application. When I request http://localhost/birthclass, I get my birthclass application.
Job done. On to the tutorials ...



22 comments:
You have saved me from 2 weeks of wild goose chase...
I was getting /post/index/ not found.. (By the way I am still trying to figure out the "BLOG App" from http://book.cakephp.org/view/219/blog
after fixing the htacess stuff as per your blog I moved to this...
http://dev.zipmediafactory.com/post/index
Controller not found but it is there just like the BLOG tutorial...
But if you point your browser to
http://dev.zipmediafactory.com/ I get all the PHpcake stuff so I know it is installed.
my phpcake is installed on
/vhost/phpcake
Please help me... what you think
myjeep_2003 AT yahoo dot com
Thank you, this was most helpful.
This is great!
I do not know why the writers of the CakePHP will think that Cake is the only thing people will have on their server and why they will not think of a production installation option where the application is under a directory not in the root of the domain.
This is absolute genius! This is at least the 10th "guide" I've read on getting stuff to work, and this is the only one that has! Beutiful!
This was very helpful! This probably goes without saying, but noobies (like me) should also be sure that their apache server has mod_rewrite enabled. Otherwise the given changes won't take effect.
Thanks for saving my skin here. I got a test-version online in time because of this tutorial, which surely wouldn't have happened were I to figure it all out by myself.
Cheers,
Wim
thanks for saving me. for the last 2 weeks I am struggling. Its you by whom i can successfully launch my site.
Cheers,
Manoj
Thanks, I was making a silly mistake in my .htaccess. Your post certainly helped me to figure it out where I was going wrong.
Cheers.
Souvik
you saved me! This solution fixed all my problems! thanks for your post!
Hello
Thank you so much I have been trying to get this to work for so long. Thank you again
thank you! that was nice trick, saved lot of time!
fuck this, going back to Rails....
Thanks for this tip!!
You save me for lot of hours attempting to solve this issue.
Thanks again :)
Thx working gud
Thanks for the instructions. I am new to cakephp. How do I set the RewriteBase in case of WAMP on windows machine.
My project structure is as follows
c:\wamp\www\tottler
so I have 3 .htaccess in
c:\wamp\www\tottler
c:\wamp\www\tottler\app
c:\wamp\www\tottler\app\webroot
So how do I specify path in each of these in this case?
Use absolute path or relative path?
i.e.
RewriteBase C:/wamp/www/tottler/
RewriteBase C:/wamp/www/tottler/app/
RewriteBase C:/wamp/www/tottler/app/webroot/
in above 3 .htaccess files?
Please help me since rewite of http://localhost/my-some-seo-link-a-html is not rewriting to products/show/$2&%{QUERY_STRING}
thanks
:)
Thank you so much!
Thank you so much, seeing my site suddenly come to life, after struggling with the .htaccess file(s), was a great joy.
Orly
Thanks man :D
Thanks Raymond. Your post helped me in fixing the issues with the setup on a windows machine. It took almost 2 weeks and finally found your post.
For me it was an issue with the rewrite base set in .htaccess files.
I am using wamp env. and had set an alias for the project as
----------------------------
Alias /emc "c:/EMC/emcsus/"
#Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
--------------------------
I had to set the rewritebase as /emc, /emc/app and /emc/app/webroot for C:/EMC/emcsus/.htaccess, C:/EMC/emcsus/app/.htaccess, C:/EMC/emcsus/app/webroot/.htaccess respectively.
Thanks again.
I have read your blog and i got a very useful and knowledgeable information from your blog.its really a very nice article.You have done a great job .
Thank you so much
Cake PHP Developmentfor sharing.
U just saved me from developing my own MVC....Thanks
Cakephp is really an amazing e commerce development platform. One must cakephp development for building applications for his business as cakephp development various benefits and features.
Post a Comment