How to config .htaccess files on of CakePHP new server - php

Whenever installed into a new hosting on website: http://binhtichapvarem.com with cpanel 11.5 troubled me about htacess file, usually will fail with error 500 and error font
I'm using a standard file format htacess
Options +FollowSymLinks
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Please guidelines for selecting the standard .htaccess file cakephp 2.5,
Thank you

Related

Nette framework Url not working on localhost

The PHP Nette framework, Url is not working on localhost. On the live server it is working fine but when I installed it on localhost from the latest backup from hosting server it does not work.
My .htaccess file is as:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ /www/$1 [L,NE]
</IfModule>
My Localhost URL on Wamp which the home page is working properly
http://localhost/ongoingclients/www/www/
But other urls are not working.
what does it mean that it is not working? It shows 404 from apache?
try to check that
mod_rewrite in apache is enabled
AllowOverride in apache vhost settings is set to All
The above issue is resolved by .htaccess of rule RewriteBase
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ongoingclients/www/www/
# prevents files starting with dot to be viewed by browser
RewriteRule /\.|^\. - [F]
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
</IfModule>
Got success, thank you.

Cakephp 3.x .htaccess issue on bluehost server.

I want to setup cakephp 3.x solution inside WP website.
On my bluehost server, I have directory structure in public_html is as follows:
I want to access stagetribescrm directory and that directory contains Cakephp 3.x file structure.
.
Code Inside of public_html/stagetribescrm/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /stagetribescrm/
# RewriteRule ^$ webroot/ [L]
# RewriteRule (.*) webroot/$1 [L]
</IfModule>
Code Inside of public_html/stagetribescrm/webroot/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And the problem with this code is that it couldn't load css and js files inside webroot folder's file.
Thanks.
Please check for rewrite module is turn on or not in bluehost server than
follow below link:
http://www.abhinavsood.com/install-cakephp-in-subdirectory-of-wordpress/

Server Internal Error 500 on CakePHP 2.0

I'm using CakePHP 2.0 for my website frameworks, I located my cakephp files on server but i have some problems, named Server Internal Error 500, I don't know what i supposed to do, the other pages is working well, but some pages is encountered a 500 server internal error, I've checked the controller, view, model, and they said is no error detected, but the firebug says, the view is missing, this is my .htaccess file
public_html/cakephp/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~magang/smkn1pst/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
public_html/cakephp/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
public_html/cakephp/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~magang/smkn1pst/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
I already following steps, by adding / ex: app/webroot/ to /app/webroot/ and webroot/ to /webroot/ but still not works for me, i need to steps up to the next project, but this problem is bugging my day.
You are using mod_userdir, when using that indeed you need the RewriteBase, as mod_rewrite removes the ~ charachter
RewriteBase /~magang/smkn1pst
in all 3 .htaccess files should work, as it does for me
Currently one of your files is missing this line
This should help fix your error.
http://ask.cakephp.org/questions/view/getting_http_1_0_500_internal_server_error_in_my_cakephp_website
i am not sure please try
RewriteBase /smkn1pst/
I had a similar problem (static files were redirected properly with the correct RewriteBase in the root htaccess).
It turned out (after 4 hours of debugging .htaccess) that my FTP client had skipped the app/tmp/ directory because of a rule I added myself.
That also yielded a 500 error.

CakePHP application cannot start in localhost

I'm trying to get a CakePHP application to work. I use xampp and put my application files in /xampp/htdocs. For .htaccess configuration I refer to http://book.cakephp.org/1.2/view/37/Apache-and-mod_rewrite-and-htaccess . After that I'm trying to run my application, but I've got this message in browser.
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
All my other applications in which I have not used the CakePHP, runs well on localhost, without any errors. I think the problem connected with .htaccess. Any suggestions ?
EDITED
My .htaccess files
**/xampp/htdocs/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>
**/xampp/htdocs/app/.htaccess**
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
**/xampp/htdocs/.htaccess**
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I think your .htaccess files look correct. You might need to tell Apache where the webroot of your app is. Try adding a vhost entry in your Apache configuration
inside \xampp\apache\conf\extra\httpd-vhosts.conf
try adding something like:
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:\xampp\htdocs\app\webroot <-(use the actual path here)
</VirtualHost>
The you should then be able to access the CackPHP app by visiting http://localhost
Be sure to remove any other VirtualHost blocks that might conflict, although if you are working with a fresh copy of XAMPP everything in this file will be commented out.
Don't forget to restart Apache for the change to take effect.

Cakephp showing errors when deployed in server

When i upload cake php in server, it gives me the following error:
URL rewriting is not properly configured on your server
Class 'PDO' not found in /home/is306t3/public_html/lib/Cake/Model/Datasource/Database/Mysql.php on line 177
I have included the htaccess file as advised by cakephp:
root htaccess as follows:
IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
app htaccess as follows:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
and finally the app/webroot htaccess as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RRewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
The directory structure of my website is
-app
--webroot
---htaccess
--- test.php
--htaccess
-lib
-htaccess
Hope someone can help. Thanks!
Sounds like an Apache configuration issue. You need to confirm that the mod_rewrite is enables on Apache. Here is an article that talks about how to enable it:
http://www.lavluda.com/2007/07/15/how-to-enable-mod_rewrite-in-apache22-debian/
If you do not have access to the Apache configuration, you will need to contact your hosting provider.
UPDATE
Oh I just noticed. Try updating your webroot/.htaccess:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Notice the ? in the rule? It should resolve it.
I'm not sure about the rewrite error but I had that PDO error as well. I had to add these two lines to the top of my .htaccess file.
Action application/x-hg-php53 /cgi-sys/php53
AddHandler application/x-hg-php53 .php
This is for HostGator though. The issue was they use php 5.2 as default for compatibility and you have to add these two lines to use 5.3 which has PDO. Maybe it will work there.
I know hardly anything about .htaccess rules but RewriteBase / isn't in any of my .htaccess files for Cake.

Categories