Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to config .htaccess files of CakePHP in WampServer?

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

like image 270
Mona Avatar asked Dec 08 '10 01:12

Mona


People also ask

Where is .htaccess file in WAMP server?

htaccess files from custom locations, the contents of this file can be found in the installdir/apache2/conf/vhosts/htaccess/APPNAME-htaccess. conf file. For example: The installdir/apache2/conf/vhosts/APPNAME-vhost.

Where to put htaccess file?

htaccess file location is most commonly found in your website's public_html folder. You can access your . htaccess file in a few different ways: From your hosting account's file management (such as via cPanel)


1 Answers

  1. Right click on the WAMP icon on your task bar
  2. Then Hover over Apache Modules
  3. Scroll down and make sure rewrite_module is ticked
like image 80
Andreas Wong Avatar answered Oct 06 '22 02:10

Andreas Wong