Only directory listing in cakephp setup - php

I have a Cakephp backup and I want to setup it on my local xampp setup. I backup it from the server in which it is running smoothly. When I want to open using localhost, it displaying the /app/webroot/ directory listing.
I am using windows 7 with xampp. I started mod_rewrite already.
my .htaccess file has
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
DirectoryIndex /front/default.php
</IfModule>

Something is wrong in your document. Your .htaccess should like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Try this code:
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^(.*)$ app/webroot/$1 [L]

Related

How to run an existing cake php project in my local using xampp server in windows

This is my webroot .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteBase http://localhost/myproject/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This is project folder .htaccess file
<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule ^(\.well-known/.*)$ $1 [L]
#RewriteRule ^$ webroot/ [L]
#RewriteRule (.*) webroot/$1 [L]
</IfModule>
This file is in app folder .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Can any one help me out with this?
Try with below htaccess codes
/var/www/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
/var/www/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/var/www/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
There can be following reasons for 500 Internal Server Error in CakePHP application:
1) Your .htaccess files are not correct.
2) Permissions of folders are not correct. If CakePHP app is Group Writable i.e. 777 then webserver gives 500 error for safety.
3) You are missing Database Connection. Correct database configuration according to Webhost because most of times local and production server databases have different details.
4) Delete the content of your tmp folder. It is best practice that you must delete cache if you move your application from one place to another.
5) For testing purpose debug should be on like configure::write('debug',2);
6) If not succeeded check your Apache Error Log. If using Linux /var/log/apache2/error.log
Hope It Helps, Thanks!!

Setup cakephp in subfolder on AWS

I had shifted my cakephp website to a subfolder on AWS ubuntu machine. Site is working but CSS, Images and JS are not loading.
I am getting 404 not found error.
Not Found
The requested URL /demo/css/mscrollar/jquery.mCustomScrollbar.min.css was not found on this server.
Urls are working only with index.php.
Here is the htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /demo
RewriteRule ^media/(.*) http://%{HTTP_HOST}/files/timthumb.php?src=http://%{HTTP_HOST}/app/webroot/files/$1 [L,R=301]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Please help
You need to create two htaccess files. One in the webroot and one in the root path.
The one in the root (./.htaccess) should look like this (replace YOUR_PATH):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /YOUR_PATH
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
The one in the webroot folder (./app/webroot/.htaccess) should look like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

cakephp installation htaccess issue

I'm trying to install CakePHP in www.domain.com/demo/realestate I changed .htaccess in root, app,webroot with ref from cakebook, S.O. and other websites. Most of them produced either 500 error or shown a blank page or 404 error.
My .htaccess code in each of those files are:
--in root--
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /demo/realestate
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
--in app--
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
--in webroot--
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I also tried to delete all .htaccess and write Configure::write('App.baseUrl', env('SCRIPT_NAME')); in app/config/core.php as per a suggestion in documentation but then it started taking demo as controller name and realestate as function name.
I request you to guide me to set it up!
There is no need to change in htaccess if you want to install cakephp in www.domain.com/demo/realestate. Just copy all cakephp files and folders in realestate folder with default htaccess and it'll work.

CakePHP issues with .htaccess file on site5 server

Building a CakePHP website for a client, it runs perfectly on my local environment, and when being tested on my server. However, when I transferred it to the client's site5 server it returned nothing but 404 errors.
After some modifications to the .htaccess files I was able to get the default landing page working fine:
http://174.120.222.98/~sty/
The issue I have, is that only the default landing page can be found. All of the sub-pages are still returning 404 errors (example: "NEW STUDENTS" Green-background link in NavBar).
I've changed the root/.htaccess file to:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~sty
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
without RewriteBase /~sty The default landing page is a 404.
I've changed root/app/.htaccess file to:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Without this change, none of the files in webroot loaded (images/styles/js).
Those two files alone seem to be all I need for the default page, I can even remove the root/app/.htaccess file and the landing page looks great. So I'm assuming the app file is the one that will govern my sub-pages. Nothing I've done to it seems to work, it is currently set to:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~sty
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
I've tried to RewriteBase with \, \~sty, \~sty\app and without the line so far none of my changes seem to work.
Help me StackOverflow, you're my only hope.
mod_rewrite is not enabled on your server so you have to handle this with .htaccess file in your root directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
and another .htaccess in your app folder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
and another one in your webroot folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

cake php gives me error when setting up on development server

First of all, I want to describe that I have researched a lot on this question so thats why I am asking so please dont downvote. I have implemented lot of solutions.
I am using cake2.0. I have uploaded a website on development server the link is http://dev.infideaco.com/eventmanager/ . But I am getting the not found error. I have resolved it by changing the .htaccess files but then the css,js and images are still not available.
I have .htaccess files which are provided by default installation. I am setting it up in development server
/var/www/dev.infideaco.com/eventmanager
The website is running fine on other servers.
You can check here:
http://swirlsyogurtbar.com/js/
These are the htaccess files:
root file:<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule sss (.*) app/webroot/$1 [L]
</IfModule>
in app:<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/.htaccess:<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Please provide me the solution. Lot of thanks in advance
I would first check if server supports mod_rewrite. Also check this thread if you haven't already: cakePHP - 404- page not found error, when deploying on a different machine
root file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
in app:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Categories