Welcome Guest, Not a member yet? Register   Sign In
Build a CI application alongside EE 2 installation
#11

[eluser]Monarobase[/eluser]
I think that you are looking at it from the wrong point of view.

Without you .htaccess rewriting you access EE controlers with

http://www.nifootball.co.uk/index.php/co...r/function

You access the CI controllers with :

http://www.nifootball.co.uk/stats.php/co...r/function

At the moment you have a rewrite that rewrites :

http://www.nifootball.co.uk/pages/home.html

to

http://www.nifootball.co.uk/index.php/pages/home/

What you need to do is to say that

http://www.nifootball.co.uk/stats/

is not redirected to

http://www.nifootball.co.uk/index.php/stats/

but to

http://www.nifootball.co.uk/stats.php/index

The routes in CI allow you to specify which controller is shown as the main index, but you have to be in the correct application for the routes config to apply.

So you don't detect if you are using a CI controller and then show stats.php but you do the opposite, you use the CI if stats.php is used and EE controllers if index.php is used.

Maybe the best solution would be to tell your .htaccess to ignore all the EE rewritings for a folder called stats and place the index.php of code igniter in this folder and give it it's own .htaccess rewriting.
#12

[eluser]Scott Boyde[/eluser]
If it was possible I didn't want to change the structure of the url to have either

http://www.nifootball.co.uk/stats.php/league/viewleague/nafl.html
or
http://www.nifootball.co.uk/stats/league/viewleague/nafl.html

But try and keep it as is now
http://www.nifootball.co.uk/league/viewleague/nafl.html

I thought that if I used routes I could do something like

$route['league/viewleague/([a-z0-9-_]+)'] = "stats.php/league/viewleague/$1";

Maybe the htaccess could add this in some way.
#13

[eluser]Monarobase[/eluser]
.htaccess can do this but it would be "cleaner" to be able to do this with routes ... Sadly I haven't explored all the capabilities of CI yet so we will have to wait and see if someone else will help you.
#14

[eluser]Scott Boyde[/eluser]
Thanks for the input, hopefully someone can point me in the right direction.
#15

[eluser]Scott Boyde[/eluser]
Was able to get it running

I now have EE2 as my main site with CI running alongside.

my htaccess is as follows

Code:
RewriteEngine On

# EE
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(pages|pages/.*|admin|admin/.*|league_admin|league_admin/.*|club_admin|club_admin/.*|leagues|leagues/.*|associations|associations/.*|assoc_cups/|assoc_cups/.*|league|league/.*|cups|cups/.*|division|division/.*|team|team/.*|reports|reports/.*)$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L]

# CI
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 ^(pages|pages/.*|admin|admin/.*|league_admin|league_admin/.*|club_admin|club_admin/.*|leagues|leagues/.*|associations|associations/.*|assoc_cups/|assoc_cups/.*|league|league/.*|cups|cups/.*|division|division/.*|team|team/.*|reports|reports/.*)$ [NC]
RewriteRule ^(.*)$ stats.php/$1 [L]

for any CI urls EE ignores them.
#16

[eluser]Ben Parizek[/eluser]
Helpful thread. Thanks. I'm trying to do just this, set up a 2nd Codeigniter app next to an EE 2 install. I've placed the codeigniter 2nd application folder in the EE system folder right alongside expressionengine:

/system/expressionengine/
/system/application2/
index.php (for EE)
application2.php (for 2nd codeigniter app)

The application2.php is the index.php straight from codeigniter. Is there any reason I should have just duplicated the EE index.php and renamed it? It seems EE 2 renames the "system/codeigniter" file to "system/core" so when I pulled in the 2nd index file I had to change one line of code. From:

Code:
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

to

Code:
require_once BASEPATH.'core/CodeIgniter'.EXT;

The welcome page works fine when I have the index file in the URL but when I can't seem to get the htaccess to remove the file from the URL. Here is my htaccess below. In its current state it works fine for the EE2 site, but the codeigniter app only displays with the application2.php in the URL.

If I remove the #EE section of the htaccess and just leave the #CI section, the codeigniter app becomes my main site and application2.php is successfully removed from the URL. Can anybody help me figure out how to get both the EE site and the Codeigniter application2 both working with clean URLs at the same time?

Code:
RewriteEngine On
RewriteBase /

# remove www
RewriteCond %{http_host} ^www.mywebsite.com [nc]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [r=301,L]

# EE
RewriteCond $1 !^(application2\.php|css|favicon\.ico|system|images|index\.php|themes) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

# CI
RewriteCond $1 !^(application2\.php|css|favicon\.ico|system|images|index\.php|themes) [NC]
RewriteRule ^(.*)$ /application2.php/$1 [L]

Thanks
#17

[eluser]Monarobase[/eluser]
I think you need to understand what your .htaccess code does ...

Code:
# EE
RewriteCond $1 !^(application2\.php|css|favicon\.ico|system|images|index\.php|themes) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

If the URI contains anything other than application2.php, css, favicon.ico, system, images, index.php or themes then take the URI and post it after index.php/

So DOMAIN.EXT/uri gets understood as DOMAIN.EXT/index.php/uri

Code:
# CI
RewriteCond $1 !^(application2\.php|css|favicon\.ico|system|images|index\.php|themes) [NC]
RewriteRule ^(.*)$ /application2.php/$1 [L]

If the URI contains anything other than application2.php, css, favicon.ico, system, images, index.php or themes then take the URI and post it after application2.php/

So DOMAIN.EXT/uri gets understood as DOMAIN.EXT/application2.php/uri

As you can see you are telling apache rewrite to rewrite DOMAIN.EXT/uri to both DOMAIN.EXT/index.php/uri and DOMAIN.EXT/uri to both DOMAIN.EXT/application2.php/uri

You must either specify a file name or a file directory for your second application.

The Easiest solution would be to create a directory called application2, place an index.php and a .htaccess in it and remove the CI lines from your current .htaccess file and replace application2\.php by application2 to stop it from parsing the URLs for your second application

I guess you could also achieve the same by making your .htaccess a bit more complicated in order to fake the directory and pass it on to application2.php

If you don't want to have application2 in the URL then you must add the complete list of your application2 functions or at least name them with the same prefix and rewrite all functions with the specified prefix to application2.php and all the others to index.php
#18

[eluser]Nathan Pitman (Nine Four)[/eluser]
Using the approach outlined here I seem to have gotten 'part' way there. I have EE2 installed and my CI app inside the EE2 system folder. I've created a new subfolder called 'app' in which I have my old CI index.php file and with system and application path adjustments this seems to be pointing at the right controller in my CI app by I just get the following error:

Code:
Fatal error: Class 'Controller' not found in /home/ihasco/subdomains/dev/system/app/controllers/training.php on line 10

Do I need to replace my index.php file from my CI app with a copy of the EE app index.php file (adjusted accordingly) or is there something else I've missed?

TIA!

*UPDATE* - I've got this sussed... just have my own mod rewrite issues to solve now! :)




Theme © iAndrew 2016 - Forum software by © MyBB