Cakephp showing errors when deployed in server - php

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.

Related

How to config .htaccess files on of CakePHP new server

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

Phalcon framework displays index of page instead of application

I wanted to use learn phalcon so i tried installing it on ubuntu. I did everything like in tutorial and i can see phalcon in phpinfo(). I made sample project like in tutorial with following htaccess files but all I can see when typing localhost/tutorial is index of /tutorial instead of Hello! message
#/tutorial/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ((?s).*) public/$1 [L]
</IfModule>
#/tutorial/public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
Try removing the <br> tags from your .htaccess files. If the previous doesn't work check your apache configs for the localhost, maybe it doesn't AllowOverride.
Also you can use the steps from here to create a virtual host on apache with it's document root set to the path of tutorial folder.
Everytime you change the configs of apache, remember to do a reload or a restart of the apache service.

codeigniter rewriting of URLS not working

In the past, I have got this working no problems at all, but for some reason on my new server I just can't get it to work.
I have the following .htaccess file in the root of my application
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I have also enabled mod_rewrite and have confirmed this with php_info()
my site is located at /var/www/html/test
Is it possible that although mod_rewrite is enabled that it is not working and if so, how can I test it?
On some server implementations, you'll need to wrap it within <IfModule> tags.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Also check your httpd.conf file to ensure it has:
Options FollowSymLinks
AllowOverride All
It'd also be worth checking to makesure the .htaccess file isn't being overridden by another .htaccess file.
A simple way to test if .htaccess is working
Simply put the following in your .htaccess file:
deny from All
What this does is deny access to your site from everyone. If you are presented with a 403 forbidden when trying to access the site - the .htaccess file is being included. If not - see above.
I use this on my codeigniter setup
RewriteEngine on
# prevent these directories from hitting CI
RewriteCond $1 !^(index\.php|images|assets|robots\.txt|crossdomain\.xml)
# route everything else to the index.php
RewriteRule ^/(.*)$ /index.php/$1 [QSA]
(my setup is done in the virtualhost of .conf and not in .htaccess, though they are usually about the same configuration)

openshift content encoding error .htaccess

I've just installed symfony2 on top of my wordpress 4.0 using the ekino-wordpress-bundle. I followed exactly the instructions here: https://github.com/ekino/EkinoWordpressBundle
Everything works fine on my localhost, a vanilla MAMP, however, when I push to openshift (also a vanilla php gear), everything breaks down and I get content encoding error.
I've tried tweaking the changes one by one and managed to narrow down the problem to the .htaccess file.
Here's the .htaccess file from wordpress that work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /webfront-interiorpediadev/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /webfront-interiorpediadev/index.php [L]
</IfModule>
# END WordPress
Here's the symfony's .htaccess that break the wordpress, but if I changed back the htaccess, I got back the "only wordpress, no symfony" stuff like before:
DirectoryIndex index.php
<IfModule mod_autoindex.c>
IndexIgnore /symfony
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .? - [L]
# Rewrite all other queries to the front controller.
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /index.php/
</IfModule>
</IfModule>
I have no idea what went wrong, as in my local MAMP, everything works perfectly with the faulty .htaccess (wordpress+symfony). Would anybody help pointing me to the right direction?
P.S: I've checked the LoadModule on both my MAMP and openshift and mod_rewrite is on. I have no idea about the rest but I think the difference is just mod_rewrite and autoindex
EDIT: the problematic url is: http://webfront-interiorpediadev.rhcloud.com/
note that all the other sub-urls are working fine, eg: http://webfront-interiorpediadev.rhcloud.com/wp-login or http://webfront-interiorpediadev.rhcloud.com/symfony/web
Since it seems that you are doing your coding on windows, and then uploading to a linux web server, you should ssh into your gear and look at those files using vim and see what they look like. It is very possible that you have some line ending issues, or that some character was copied as an html entity that shows up correctly in your IDE, but is not parsed correctly by the server.

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.

Categories