2009-08-26 18 views
19

Sto provando a far funzionare un'applicazione CakePHP. Per questo, ho creato una nuova installazione di Debian, aggiornato la configurazione e mettere tutto in/var/www, che ha il seguente contenuto:.htaccess per cakephp

app 
cake 
.htaccess 
index.php 
vendors 

Il file .htaccess contiene quanto segue:

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

Se accedo al mio virtualhost (http://myhost/), vedo la pagina corretta. Ma anche il JavaScript caricato con src="/js/validate.js" fallisce (si trova all'interno /var/www/app/webroot/js/validate.js):

[Wed Aug 26 15:45:12 2009] [error] [client 10.7.10.52] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3063): [client 10.7.10.52] r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /js/prototype.js 
[Wed Aug 26 15:45:12 2009] [debug] mod_deflate.c(632): [client 10.7.10.52] Zlib: Compressed 649 to 405 : URL /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js 

Da qui la mia domanda : qual è la .htaccess appropriato per la CakePHP?

Molte, molte grazie!

+1

Quale directory hai per la root del sito nella tua configurazione di apache? Dovrebbe essere/var/www/app/webroot - che potrebbe risolvere il tuo problema. – inkedmn

+0

@inkedmn: grazie, sarebbe/var/www - ma l'errore era perché stavo usando solo un .htaccess, non 3, come ho appena scoperto. Grazie! – MrG

risposta

55

La risposta è che ci sono 3 diversi file .htaccess:

/var/www/app/webroot/.htaccess

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

/var/www/app/.htaccess

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

/var/www/.htaccess

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

È stata colpa mia, tutto è elencato su CakePHP site. Grazie a tutti!

+0

Dopo aver trovato i miei file di log e aver cercato su Google gli errori che hai elencato sopra, ho trovato questo! Grazie mille! – DirtyBirdNJ

+0

ottima risposta ......... ha funzionato per me –

+0

grazie ... mi ha aiutato molto :) – Alex

2

la correttezza .htaccess è il default:

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

Bisogna aggiungere questo in "/ etc/apache2/sites-enabled/default":

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

se la sezione esiste già il cambiamento AllowOverride Nessuno per AllowOverride All

0

La rimozione di .htaccess dal file principale può risolvere questo problema. Ha funzionato per me (non è necessario rimuovere dal Webroot)

0

se consentito dal provider puoi mettere tutto nel file httpd.conf come seguire

<Directory /var/www> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all 
    <IfModule mod_rewrite.c> 
     RewriteEngine on 
     RewriteRule ^$ webroot/ [L] 
     RewriteRule (.*) webroot/$1 [L] 
    </IfModule> 
</Directory> 

E così via per gli altri indici ...