Mod Rewrite on Godaddy Shared Hosting

By colby guyer (Kirby)
For those having trouble getting cake to work on godaddy.
To get cake to work on a godaddy shared linux hosting account.
1. Upload cake to the server, unpacked before uploading is best.
2. For these instructions to work, the domain has to be set to the root of the cake folder. i.e. domain.com or subdomain.domain.com will work. domain.com/cakephp has not been tested with these instructions
3. Alter 3 .htaccess files
.htaccess in root folder of cake, change the file to read this:
Download code
<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
   
</IfModule>

.htaccess in /app/ folder:
Download code
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
 </IfModule>

.htaccess in /app/webroot/ folder:
Download code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L] 
</IfModule>

Let me know if this was helpful or you can build off of it!

 

Comments 825

CakePHP Team Comments Author Comments
 

Comment

1 Slow cakePHP if httpd.conf not changed.

Anyway, it's kinda slow when you use those .htaccess files and all the override on cakePHP.
Posted Oct 24, 2008 by Jin Lei
 

Comment

2 Thanks Kirby, it work for me.

I have a share hosting on godaddy.com, and i also host multiple domains on it, and sub-domains.
My cake's application is host on root directory, and others domains, sub-domain is host on sub-directory : /blog, /forums...

To work on sub-directory, i have added this .htaccess file to sub-directory:
Ex: in directory: /blog, add this .htaccess file

View Template:


<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /blog/ 
</IfModule>

Thank you very much.

Posted Nov 21, 2008 by Ho Duc Giap
 

Comment

3 Works but Sloooooowwwww.

Thanks for the info. This worked for me. But it is slow. Any suggestions for improving speed with this fix?
Posted Jan 26, 2009 by Bob King
 

Comment

4 Works but......

This worked but the RSS and comments rss give me 404 errors for the blog. What else should I put in the .htaccess to make it work? The two links that give 404 errors are: http://mywebsite.com/blog/feed/ and http://mywebsite.com/blog/comments/feed/
Any ideas?

I have a share hosting on godaddy.com, and i also host multiple domains on it, and sub-domains.
My cake's application is host on root directory, and others domains, sub-domain is host on sub-directory : /blog, /forums...

To work on sub-directory, i have added this .htaccess file to sub-directory:
Ex: in directory: /blog, add this .htaccess file

View Template:


<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /blog/ 
</IfModule>

Thank you very much.

Posted Mar 19, 2009 by Kerry Fitzgerald
 

Comment

5 There's a faster solution

@Bob King as well:

I also ran into the same issue of the website behaving sooo slow on applying this three level mod_rewrite solution. Finally after 30-40 minutes of debugging, I resorted to an easier solution that's also a simpler fix:

It's just the slash prefix on index in the webroot level. I've posted the solution in detail on my blog at TechieDesi Developer Community, let me know if it works for you guys:

http://techiedesi.com/post/327-setup-cakephp-modrewrite-to-work-with-godaddy-shared-linux-hosting-package

Cheers,
Cerulean
Posted May 4, 2009 by ceruleancode
 

Comment

6 Thanks

Thanks for information :)
Posted Jul 4, 2009 by Daniel