Setup CakePHP mod_rewrite to work with GoDaddy shared Linux hosting package

Posted in Blogs and articles on May 4, 2009 at 11:32 IST (9 months ago). Subscribe to this post Bookmark and Share Email
Showing comments 1 to 5 of total 5 on page 1 of 1
Post reply
« Previous1Next »

I was getting into different issues after deploying my Cake PHP website to my shared linux hosting account at GoDaddy.

Basically, this is the setup I have (as per the cake standard of pointing the root of the website to app/webroot):

mysampledomain.com points to ~/html/siteroot/mysampledomain.com/app/webroot.
When I load up http://www.mysampledomain.com, I'm getting thrown at with a 500-Internal Server error.

After 30-minutes of debugging around different .htaccess files of cake, I finally figured out two solutions. One is to point the domain to /html/siteroot/mysampledomain.com instead of app/webroot. This one, also documented at Cake's bakery website seemed too darn slow to me to afford as a solution.

Here's what I ended up with. Amazingly it turned out to be an easier fix.

For the fix to work, modify your app/webroot/.htaccess file to read the following:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
The only change I have made is the extra slash (/) prefix added to index.php. No double, triple rewrites and not even a bit slower than you would expect. 

Happy baking!

Posted by ceruleancode on Monday, May 4, 2009, 11:32 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment
Thank you this is a great site (and snippet)
Posted by anonymous on Friday, June 26, 2009, 1:18 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment
How do you point the root of the website to app/webroot in goDaddy as per the sample below?

mysampledomain.com points to ~/html/siteroot/mysampledomain.com/app/webroot
Posted by anonymous on Wednesday, September 2, 2009, 8:04 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

You don't need to do that step, it's just that I mentioned where is my webroot directory located in GoDaddy's filesystem. Your path will be different.

Two ways to figure this out are

  1. If you have enabled SSH access, just type pwd in the prompt
  2. Upload a file with <?php phpinfo(); ?> and access via a browser.
Posted by ceruleancode on Wednesday, September 2, 2009, 3:02 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment
Brilliant!! Many thanks.
Posted by anonymous on Wednesday, October 28, 2009, 5:13 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment
Pages: « Previous1Next »

Post your comment (No registration required)

  Add my comment  

TechieDesi Community

Not signed in (Sign-in or Register)
Be a true TechieDesi!
Top 10 Users
Spread the word
Invite your friends
Fan stuff
Help us improve
Need Help
FAQ's
Search tips
Found a bug? Report!
Feeds and letters
Subscribe via RSS
Archives
Subscribe to newsletter
Unsubscribe e-mail
Miscellaneous
Privacy policy
Visit rootnerve
About us
About us
Support the development
Official Blog
Advertise with us
Careers
Copyright (c) 2008, TechieDesi.com. All rights reserved | About us | Do-Not-Disturb registry | Powered by rootnerve | Page rendered in 0.238 seconds