CodeIgniter Forums

Full Version: htaccess problem with Multiple Applications
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I am trying to set up a dual-app installation of CI. I have an index.php file for the user app, and an admin.php file for the administrator app. I have run into a problem: I found a StackOverflow question that seemingly has the exact same problem as me, however, the solution that the poster found does not work for me. I have played with the RewriteRules but nothing seems to work. The two rules I have set for redirecting anything with admin at the beginning aren't being met, so the 'catchall' rewrite rule at the bottom meant for the 'app' app redirection. The syntax for the pattern section of RewriteRule seems very straightforward (I'm not THAT bad with regex), so why doesn't it work?


The htaccess rules are:

RewriteEngine On
RewriteBase /dev/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin$ admin\.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin\/(.*)$ admin\.php/$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index\.php/$1 [L,QSA]

Essentially what I need is:

type in - the url keeps the admin folder, and redirect the user to admin.php

type in - same as above

type in - the user gets directed to the app instead of admin (index.php)

In testing the person in the aforementioned post's htaccess, which mine are essentially copied from, in an online tester, the two rules involving URIs with 'admin' in it are not passed for some reason. I can only get admin (not ^admin$) to work as a pattern (according to the tester).