500 Errors With 1and1 Hosting/Apache 1.x
When I uploaded a Cake-based site to a 1and1 shared hosting account, I got some mysterious 500 errors despite the site working perfectly on my dev machine.
I don't know if 1and1 is just weird or if it's an Apache 1.x issue but when I uploaded my Cake-based site from my dev computer where it was working perfectly running on Apache 2.x to my 1and1 account, I was getting 500 Internal Server Errors.
What worked for me was to change the three .htaccess files as follows:
root .htaccess file
Download code
app/.htaccess
Download code
app/webroot/.htaccess
Download code
Note the added slashes. Also, this works for when Cake is the root folder of your website, i.e. you simply go to www.example.com, not www.example.com/path/to/cake.
If you do have your site in a sub-folder, like www.example.com/path/to/cake, use the following instead:
root .htaccess file
Download code
app/.htaccess
Download code
app/webroot/.htaccess
Download code
Hope this saves someone days of frustration.
What worked for me was to change the three .htaccess files as follows:
root .htaccess file
Download code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
</IfModule>
app/.htaccess
Download code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /webroot/ [L]
RewriteRule (.*) /webroot/$1 [L]
</IfModule>
app/webroot/.htaccess
Download code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
Note the added slashes. Also, this works for when Cake is the root folder of your website, i.e. you simply go to www.example.com, not www.example.com/path/to/cake.
If you do have your site in a sub-folder, like www.example.com/path/to/cake, use the following instead:
root .htaccess file
Download code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /path/to/cake/app/webroot/ [L]
RewriteRule (.*) /path/to/cake/app/webroot/$1 [L]
</IfModule>
app/.htaccess
Download code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /path/to/cake/app/webroot/ [L]
RewriteRule (.*) /path/to/cake/app/webroot/$1 [L]
</IfModule>
app/webroot/.htaccess
Download code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /path/to/cake/app/webroot/index.php?url=$1 [QSA,L]
</IfModule>
Hope this saves someone days of frustration.
Comments
Comment
1 Use RewriteBase insted
root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
And this way, you can just change the RewriteBase quickly to /path/to/cake later or back again and you only had to edit one line per file, instead of two (or more for other applications). Unless you disagree, I think you should reflect this in your article.
Comment
2 probably
Comment
3 Thanks
Comment
4 Frustrating
Comment
5 MultiViews Vs FollowSymlinks