Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fixing cakephp .htaccess/mod_rewrite for shared hosting setups

I'm trying to install cakePHP on a shared hosting setup. After extracting the files to a location like ~/public_html/dev/cake and visiting the appropriate URL (in this case http://hostname/~username/dev/cake/), I receive a 404 error:


Not Found

The requested URL /usr/home/username/public_html/dev/cake/app/webroot/ was not found on this server.


I suspect that the reason for this is that upon closer inspection, the absolute path to ~/public_html is not in fact /usr/home/username/public_html, but rather /usr/www/users/username/.

Here's what I've been trying (but obviously it's not working): (~/public_html/dev/cake/app/webroot/.htaccess)

<IfModule mod_rewrite.c>  
    RewriteEngine On  
    RewriteBase /usr/www/users/username/dev/cake/app/webroot/ 
    RewriteCond %{REQUEST_FILENAME} !-d  
    RewriteCond %{REQUEST_FILENAME} !-f  
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]  
</IfModule>  

Unfortunately, this doesn't seem to change anything (the 404 message remains that same). Thoughts?

like image 663
user117643 Avatar asked Jun 04 '09 20:06

user117643


4 Answers

Shouldn't

RewriteBase /usr/www/users/username/dev/cake/app/webroot/ 

be

RewriteBase /~username/dev/cake/

RewriteBase cares about mapping real urls to virtual ones, and I think that's what you want.

like image 107
artlung Avatar answered Oct 22 '22 08:10

artlung


You're modifying the wrong file. The .htaccess file you need to modify is found in /dev, you shouldn't be modifying the one in /dev/cake/app/webroot/.htaccess

like image 26
Simon Avatar answered Oct 22 '22 06:10

Simon


I just want to point out that I THOUGHT the module was loaded because I saw the code but apparently it was not enabled!

To enable it in SSH (terminal) type the following command

sudo a2enmod rewrite

The command below shows all modules that are active, if it appears in the list then you have it installed.

apache2ctl -M

Make sure to restart the server with...

service apache2 restart

PhpCake should start working now.

like image 2
Joe Avatar answered Oct 22 '22 08:10

Joe


Why not just extract the files to /usr/www/users/username/?

like image 1
David Z Avatar answered Oct 22 '22 06:10

David Z