Reputation: 788
I'm absolutely confused about what I must do to run my sample in CakePHP...
I'm using WAMP Server and it is located in "C:/program files/wamp/" and I use another partition for my projects: "E:/Projects/".
there is a folder for Learning CakePHP: "E:/Projects/cakephp/". I've put all the CakePHP extracted contents in that folder (consist of: index.php, .htaccess, readme.txt and folders: app, cake, plugins, vendors)...
First, I set an alias name (test) in Apache that pointed to "E:/Projects/cakephp/", and it didn't work (message: Oops! This link appears to be broken.)
After some search, I found that I must set the alias to another folder: "E:/Projects/cakephp/app/webroot/", and it worked perfectly and showed me the first page of CakePHP Framework.
I solved all the issues in the first page (using the CakePHP manual). I tried to follow CakePHP blog tutorial ... I made a model, a controler and a view page (all related to "posts" subject), but when I try to see the result I just received the first page of WAMP server (showing that there is some problem in the address)
I used the address: "http://localhost/test/posts/index" (that didn't work) then, I tried to put index.php in the url: "http://localhost/test/index.php/posts/index" and it worked!
.htaccess files when I try to reach the root "http://localhost/test/" work perfect, I don't know what's wrong!
xx I found the same question in StackOverflow, here . All of its settings is similar to mine except it seems he set the alias to the root of CakePHP, and it didn't work for me!
and actually I couldn't find how I can use the solution (link) that helped him, because I think it is a little different in my case!
My htaccess files for following cakephp folders are as following,
root of the cakephp
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /test/
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
</IfModule>
/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /test/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
I hope someone can help me, I'm really exhausted...
thanks in advance for your time and your solutions!
-------------------------------------------------------------------------------
Yoohoooo! I found the answer! I had made many changes in all of my htaccess files! If you have this problem too, first remove all of your changes and then use this link as a great help! Hope it help you too! CHEEEEERS! MANY CHEEEEERS!! :D
Upvotes: 5
Views: 15675
Reputation: 21
I had same issue and here is solution that worked for me
this is my cakephp.conf
in wamp server
Alias /cakephp "d:/wamp/apps/cakephp/app/webroot"
<Directory "d:/wamp/apps/cakephp/app/webroot">
Options FollowSymLinks
AllowOverride all
Require local
</Directory>
This is .htaccess
file in /cakephp (not changed anything)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /webroot/ [L]
RewriteRule (.*) /webroot/$1 [L]
</IfModule>
This is .htaccess
file in /cakephp/app (not changed anything)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /webroot/ [L]
RewriteRule (.*) /webroot/$1 [L]
</IfModule>
This is .htaccess
file in /cakephp/app/webroot (changed)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cakephp
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /webroot/index.php [QSA,L]
</IfModule>
I just added line this line
RewriteBase /cakephp
After this I was able to launch url localhost/cakephp/index.php/posts/index
Hope this will help you to get started with CakePhp using WAMP Server
Upvotes: 2
Reputation: 5240
I actually got the same issue as you, but I don't remember how I solved it.
What I can assure you it's not a .htaccess issue, but a configuration error of Apache.
I think the part I modified was this one.
<Directory />
#Options +Indexes
Options FollowSymLinks
AllowOverride All
#Order deny,allow
#Deny from all
</Directory>
Note how I commented some lines. Altough I can't confirm this, since I don't have the default configuration file.
Upvotes: 2
Reputation: 60506
Upvotes: 14