I've been stuck for a few hours over this. I found lots of information online but nothing that solved my issue.
I'm hosted on Dreamhost with a custom PHP installation (5.2.14).
The site returns a 500 Internal Server Error with this .htaccess file.
It looks like the rewrite rule is also applied to my php.cgi file but I don't know how to avoid that.
My log file shows that there is an infinite loop somewhere "Request exceeded the limit of 10 internal redirects due to probable configuration error".
<IfModule mod_actions.c>
Options +ExecCGI
AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi
</IfModule>
<FilesMatch "^php5?\.(ini|cgi)$">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
</FilesMatch>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
app/.htaccess :
RewriteEngine On
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
And app/webroot/.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Any help would be appreciated!
Thanks.
I suppose it could be your cgi. Try something like this?
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
You'll also want to make sure there isn't something goofy going on in your app/webroot/.htaccess It might be helpful to post both here.
Related
I am deploying my app on a live server hosted on 1and1.co.uk.
I am trying to make it work since 8 and getting crazy, trying with a fresh version downloaded from the cakePHP website.
Here is my configuration.
A subdomain pointing to a directory :
subdomain.mydomain.com => /subdirectory
So I think the first question is, on the view of my app, is that a subdirectory ?
I don't think so but I am not sure.
I tried hundreds of .htaccess configurations, nothing works, I get a 500 error or the following message:
Parse error: syntax error, unexpected '=', expecting '(' in /homepages/41/d201409564/htdocs/hire/lib/Cake/bootstrap.php on line 173
I thought that topic would fix my problem, but still not working.
Thanks for your help
Could fix it finally thanks to : http://www.grafikart.fr/forum/topic/2351
Here is the solution, the trick is probably to enforce the PHP5, even if it's activated on your server (which is my case)
/.htaccess
AddType x-mapp-php5 .php
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/app/.htaccess
AddType x-mapp-php5 .php
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot/.htaccess
AddType x-mapp-php5 .php
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
If someone struggles about this with CakePHP 4.xx, this is how i got it running at IONOS (former 1and1). CakePHP is installed in a Subdirectory:
(Maindirectory)
Subdirectory (CakePHP)
/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
#the next two lines are only for forwarding to https
RewriteCond %{SERVER_Port} !=443
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
# end of forwarding
RewriteBase /
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
webroot/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have uploaded my application on bluehost server. I have uploaded it on public_html.
htacces on root
/.htaccess permission 644
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/app/.htaccess permission 644
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot/.htaccess permission 644
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
url is http://consumersinchrist.org/. Please help.
Go to cpanel->PHPConfig and enable FastCGI , it will work like a charm :)
Is this a new host for you? When I switch hosts, there's usually a unique small configuration that needs to be done to get my custom apps to work.
Check out these links from BlueHost:
Help 1
Help 2
I have my site www.mysite.com in /var/www/
and I added my cakephp app in /var/www/developer
when I go to www.mysite.com/developer I get the login page fine and after I login the app takes me to the home page OK. But whenever I click on other link I get
"Page not found"
I have 3 htaccess
/var/www/developer
/var/www/developer/app
/var/www/developer/app/webroot
What should I put on those to make my urls work?
Thanks
Your .htaccess files should probably look like this:
/var/www/developer
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/var/www/developer/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/var/www/developer/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
You also should have right paths defined in /var/www/developer/app/webroot/index.php
instead of
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
try something specify the right way (eq. DS . 'www' . 'develop')
usually it is enough to redefine just CAKE_CORE_INCLUDE_PATH but sometimes youe needed define all three ROOT WEBROOT_DIR nad CAKE_CORE_INCLUDE_PATH
I have the following directory tree in public_html folder:
/app
/test
/cake
...
/app if the Application folder for my site and /test is a subdomain.
The problem is that I've changed the .htaccess, my site is working but the subdomain is returning a 500 error.
My .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Thanks.
Try this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain.com$
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain.com$
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Add the RewriteCond below to prevent an infinite internal redirect, which could result in a 500 error
#skip processing existing files e.g css. png etc
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^$ app/webroot/ [L]
#if not already /app/webroot to prevent infinite internal redirect
RewriteCond %{REQUEST_URI} !^/app/webroot/ [NC]
RewriteRule (.*) app/webroot/$1 [L]
500 error usually means something is wrong with the code, like a missing ; in your model, view or controller. Try double-checking that?
I have a CakePHP installation in a sub folder in my server, I want to install another application inside that subfolder:
root/public_html/subfolder/cake/
root/public_html/subfolder/app/
etc. now I need a custom application installed there:
root/public_html/subfolder/my_custom_application/
I have something like this in my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
How can I configure it to exclude the "my_custom_application" folder from that rules?
I tried this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule ((?!my_custom_application).*) app/webroot/$1 [L]
</IfModule>
But I get this:
Error: The requested address '/y_custom_application' was not found on this server.
Thanks in advance.
Mauricio.
How to Exclude a Directory from CakePHP Routing:
I ran into the same problem as you. I struggled, but finally found something that worked.
(I'm replying because the answer above didn't work for me, but this did).
My directory structure:
root/public_html/app/
root/public_html/lib/
root/public_html/plugins/
root/public_html/vendors/
root/public_html/directory_to_exclude/
What I added to CakePHP's default routing:
RewriteCond %{REQUEST_URI} !^/directory_to_exclude/(.*)
Effectively, I needed to allow people to access the subfolder separately (since that has a separate application). Also, in my case, I'm serving a CakePHP application by default from the root directory.
So here's what my CakePHP 2.x htaccess looks like:
Updated .Htaccess (this works for me)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/directory_to_exclude/(.*)
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
In your case, I understand you need this to work in a subfolder; here's my adjusted htaccess I didn't have a chance to test this, but I believe this (or something close) will work:
The Final Product (for a subfolder)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/subfolder/directory_to_exclude/(.*)
RewriteRule ^$ subfolder/app/webroot/ [L]
RewriteRule (.*) subfolder/app/webroot/$1 [L]
</IfModule>
Put this before the RewriteRule lines:
RewriteCond %{REQUEST_URI} !^/my_custom_application
You have to replace dir_to_exclude by your dir name.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(?:dir_to_exclude)(?:$|/)
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/(?:dir_to_exclude)(?:$|/)
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
If you want to have more than one excluded directory you have to add them separated by |additional_dir_to_exclude
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(?:dir_to_exclude|additional_dir_to_exclude)(?:$|/)
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/(?:dir_to_exclude|additional_dir_to_exclude)(?:$|/)
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>