/ / CodeIgniter mehrere anwendungen htaccess - php, .htaccess, codeigniter

CodeIgniter mehrere Anwendungen htaccess - php, .htaccess, codeigniter

Ich möchte mein CI nicht in mehrere Anwendungen aufteilen. Ich sollte sagen, dass es sich in einem Ordner namens app im Stammverzeichnis / var / www / app / befindet. Zuerst habe ich dieses Setup ausprobiert:

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

Aber ich konnte meinen htaccess nicht dazu bringen, richtig zu zeigen. Deshalb ging ich so vor:

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

Und jetzt funktioniert es gut mit URLs: mysite.com/app/app1/index.php/welcome - aber ich möchte index.php von der URL verstecken. Deshalb sieht mein .htaccess so aus:

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

Allerdings funktioniert es nicht, ich bekomme 404 beim Versuchum auf mysite.com/app/app1/welcome zuzugreifen. Könnte jemand klären, was mit meinem .htaccess falsch ist? Ich habe eine andere .htaccess-Datei im Stammverzeichnis und werde von dort aus WordPress ausführen. Würde sich dies jedoch auf meinen / app-Ordner auswirken, in dem CI ausgeführt wird? Ich danke dir sehr!

Antworten:

2 für die Antwort № 1

Versuchen Sie, diesen in jeden Ordner (von ...) einzufügen 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 für die Antwort № 2

Funktioniert es, nachdem Sie eine RewriteBase-Direktive hinzugefügt haben?

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

0 für die Antwort № 3

Okay, es funktioniert jetzt. Nach ein paar Stunden Debugging. Ich bin mir nicht sicher, was genau den Trick gemacht hat, aber ich glaube, ich habe einen verpasst AllowOverride All in meinem standard vhost. Nach dem Neustart von Apache und diesem Zugriff in jedem / app / app1 / -Ordner hat es funktioniert:

RewriteEngine on

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

Vielen Dank an alle, die zu meiner Frage beigetragen haben.