/ / CodeIgniter applicazioni multiple htaccess - php, .htaccess, codeigniter

CodeIgniter multiple applications htaccess - php, .htaccess, codeigniter

Non voglio dividere il mio elemento della configurazione in più applicazioni. Dovrei dire che si trova in una cartella chiamata app sul root / var / www / app /. Prima ho provato questa configurazione:

/system/
/application/
/app1/
/app2/
app1.php
app2.php
.htaccess

Ma non sono riuscito a far puntare correttamente il mio htaccess. Pertanto sono andato avanti con questo:

/system/
/app1/
.htaccess
/application/
index.php
/app2/
.htaccess
/application/
index.php

E ora funziona bene con urls: mysite.com/app/app1/index.php/welcome - ma vorrei nascondere index.php dall'URL. Pertanto il mio .htaccess è simile al seguente:

RewriteEngine on
RewriteCond $1 !^(index.php|gfx|css|js|robots.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Comunque non funziona, ottengo 404 quando provoper accedere a mysite.com/app/app1/welcome. Qualcuno potrebbe chiarire cosa c'è che non va nel mio .htaccess? Ho un altro .htaccess sul root e eseguirò un po 'di wordpress da lì, ma influenzerebbe la mia cartella / app dove viene eseguito CI? Grazie mille!

risposte:

2 per risposta № 1

Prova ad aggiungere questo su ogni cartella (da http://codeigniter.com/wiki/mod_rewrite):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#"system" can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn"t in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename "application" to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn"t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don"t have mod_rewrite installed, all 404"s
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>

0 per risposta № 2

Funziona dopo aver aggiunto una direttiva RewriteBase?

RewriteEngine on
RewriteBase /app1/
RewriteCond $1 !^(index.php|gfx|css|js|robots.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

0 per risposta № 3

Bene, ora funziona. Dopo alcune ore di debug. Non sono sicuro di cosa abbia funzionato, ma penso che mi mancasse un AllowOverride All nel mio vhost predefinito. Dopo il riavvio di apache e questo htaccess in ogni cartella / app / app1 / ha iniziato a funzionare:

RewriteEngine on

RewriteCond $1 !^(index.php|gfx|css|app|js|robots.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Grazie a tutti coloro che hanno contribuito alla mia domanda.