Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakephp doesn't work url-rewriting on Ubuntu

all. This time I try cakephp, but I have got "URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don't / can't use URL rewriting". I could know this is apache and .htaccess issues such as /etc/apache2/sites-avaliable/default and each directory .htaccess.

My development environment...

  • Ubuntu12.04 on vmware fusion4
  • apache2.2.22
  • mysql5.5
  • php5.3.10
  • cakephp2.1

My process is followed...

1)/etc/apache2/httpd.conf

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

2)enabling mod_rewrite

sudo a2enmod rewrite
sudo service apache2 reload

3)editing /etc/apache2/sites-avaliable/default (AllOverride None to AllOverride All)

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>

prompt: sudo service apache2 reload

4)editing or checking each .htaccess file ->cake root directory

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
   </IfModule>

->app root directory

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$    webroot/    [L]
   RewriteRule    (.*) webroot/$1    [L]
   </IfModule>

->webroot directory

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

This issue is solved, thank you.

like image 827
Shinya Ota Avatar asked May 31 '12 14:05

Shinya Ota


1 Answers

I had this problem as well. Turns out the .htaccess file was not getting copied alongside the cakePHP source. This is a common issue when using the cp command or not having hidden files visible in a file browser, unless you copy the top-level directory.

Doing a direct copy of the file to my project folder fixed it for me without having to mess with my apache settings.

cp ~/git/cakePHP/.htaccess ~/project/folder/
like image 189
NuclearPeon Avatar answered Oct 28 '22 12:10

NuclearPeon