Welcome Guest, Not a member yet? Register   Sign In
code igniter alongside existing php
#1

[eluser]Unknown[/eluser]
So after a bit of searching and a bit of wrangling, I've basically got what I'm looking for except when a directory is protected by an HttpAuth in an .htaccess file.

Here's what I have, and what I'm looking to do... and I may be thinking about this a bit backwards so I'm welcome to alternative suggestions.

/ci_app
/ci_app/controllers/private.php
/ci_app/controllers/public.php
/ci_system
/htdocs
/htdocs/.htaccess
/htdocs/ci.php --ci file
/htdocs/index.php --regular non-ci php
/htdocs/private
/htdocs/private/.htaccess
/htdocs/private/index.php
/htdocs/public
/htdocs/public/index.php

Things that work as expected:
http://www.site.com --> displays index.php
http://www.site.com/public --> displays public/index.php
http://www.site.com/public/a_ci_function --> displays a_ci_function() in /ci_app/controllers/public.php
http://www.site.com/private --> displays private/index.php
http://www.site.com/ci.php/private/a_ci_function --> displays a_ci_function() in /ci_app/controllers/private.php

Only when I try to load:
http://www.site.com/private/a_ci_function
do I get an infinite loop in the browser (blank page, and status bar flashes between "connecting to" and "waiting for"). I assume something in my mod_rewrite is making it loop (perhaps because it can't auth? because I don't get this loop in the folder that isn't protected).

/htdocs/.htaccess
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(private)
RewriteRule ^(.*)$ /ci.php/$1/ [L,NS]

/htdocs/private/.htaccess
Code:
AuthType Basic
AuthName "Private Folder"
AuthUserFile /path/to/passwd/outside/docroot/.passwd
require valid-user

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ci.php/private/$1/ [L,NS]

The reason I'm trying to have it setup this way is because the site has a ton of existing code currently, but as I create new parts or update existing ones, I'd like to use CI and eventually move/merge into a completely CI app. Right now I want the flexibility of being able to have both the CI and the old code working together... but perhaps I should rethink what I'm trying to accomplish.

I did consider ignoring the private directory in the top-level .htaccess, and then creating a separate CI app for the private directory, but it seemed a bit kludgey as the main goal is to work towards 1 united CI app.




Theme © iAndrew 2016 - Forum software by © MyBB