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.
Related
Long story short, I updated an e-commerce website but had to install the new static CMS system into a sub-directory (/wear). The main e-commerce store is still sitting in the root directory (/), and due to the large amount of products and SEO impact, I need to leave it there.
I would like to setup a requests for just index.php to redirect to /wear/
At the same time, if there is a request for index.php?XXXXX I would like it to still use the index.php file.
I've tried using the following .htaccess code but it's redirecting everything. Can anyone help me with this? I apologize for asking this as I know there are multiple threads, but none seemed to provide a good answer.
Attempt 1
RedirectMatch /index.php https://domain/wear/
Attemp 2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wear/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The issue comes from your RewriteBase. When setting it up to /wear/, RewriteRule ^index\.php$ - [L] actually translates to RewriteRule ^wear/index\.php$ - [L] which is not really what you want.
I would try something like this:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^index\.php$ /wear/ [L,R=301]
What it does is: check that the query string is empty, and if it is, redirect index.php (at the beginning of the request URI, so /index.php only) to /wear/
You will also need to make sure than mod_rewrite is active.
To do so, you can remove the <IfModule mod_rewrite.c> and </IfModule> parts. If mod_rewrite is not available, it will trigger an Error 500 as the RewriteEngine command will not be recognised.
So, I moved the website.com to subdomain.website.com. The .htaccess file is located in the website.com/subdomain/ folder, it should work but it's not working.
Error message: The requested URL /title-123 was not found on this server.
Basically what it does is translates the website.com/product.php?id=123&title=hello to website.com/hello-123
The error is produced when trying to access subdomain.website.com/title-123
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/product\.php\?id=([0-9]+)&title=([^\s&]+)\s [NC]
RewriteRule ^ %2-%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+?)-([0-9]+)$ product.php?id=$2&title=$1 [L]
</IfModule>
Anyone knows how to fix this? Thanks!
After a lot of research and debugging of apache conf files and receiving expert's assistance i managed to fix it removing completely the .htaccess file and adding the rewrite rules in the apache VirtualHost directly.
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.
I have a custom MVC app, where in it used IndexController naming convention, which I have built on WAMP. Today i tried it to put in to Linux (LAMP).. Strangely, it is giving error "page not found". Can anybody help. I am not good at mod rewrite,
Following is the code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?request=$1 [L,QSA]
URL is
http://hostname/mvc/incident/add
Error is The requested URL /app01/users/public_html/mvc/index.php was not found on this server.
You need to put a / before index.php and some other stuff. Look at the example I got from Wordpress's one.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Try either adding:
RewriteBase /mvc/
just under the RewriteEngine on directive, or add a leading slash to index.php:
RewriteRule ^(.*)$ /mvc/index.php?request=$1 [L,QSA]
Hi I solved this issue by using error redirecting functionality. I put following code in my .htaccess file
ErrorDocument 403 /~renjith/mvc/index.php
ErrorDocument 404 /~renjith/mvc/index.php
and in index.php file i used, $_SERVER['REQUEST_URI'] to get thr URL with query strings
I think that ./htaccess configuration is correct. I solved it simply by adding this directive to my apache2.conf file on debian.
<Directory /var/www/html/your_app_folder>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted</Directory>
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.