Welcome Guest, Not a member yet? Register   Sign In
Multiple sites, one install works great. But how can I avoid using multiple PHP files for each app?
#1

[eluser]dallen33[/eluser]
For example, I have a URL like this:

http://myurl.com/app1

Right now, app1 is a folder that contains an index.php telling it where the app folder and system folder is. I don't like this.

Is there a way I could have index.php at the webroot look for an application based on the uri segment (in this case, app1)?
#2

[eluser]Georgi Budinov[/eluser]
Hello

actually you asked a very good question here. That's a nice feature if we could do it. So I was interested in that so I tried and found a solution - Mod Rewrite. I didn't know that but using it one can change and set environment variables ... so I go like this in the .htaccess:

Code:
RewriteEngine on

RewriteCond $1 !^(index\.php)
RewriteRule ^([^/]+)/(.*)?$ - [E=PATH_APPLICATION:$1,NE]

RewriteCond $1 !^(index\.php)
RewriteRule ^([^/]+)/(.*)?$ index.php?/$2 [L]

This removes the need of index.php and together with that sets $_SERVER['REDIRECT_PATH_APPLICATION'] variable to the first segment of the url. And codeigniter should be working as supposed. Nice! So you just need to get that variable and set url to the application folder accordingly Smile

Enjoy!
#3

[eluser]dallen33[/eluser]
Very cool! Thanks for the response.

Unfortunately, I'm stuck on IIS7, so I'm using rewrite's with web.config. Currently, mine looks like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ci_rule_01" stopProcessing="true">
                    <match url="(index.php|robots.txt|sitemap.xml|extras|info.php|favicon.ico)" />
                </rule>
                <rule name="ci_rule_02">
                    <match url=".*" />
                    <action type="Rewrite" url="index.php/{r:0}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
Do you have any idea how I would update it to do what your .htaccess would be doing? I'm definitely no expert at IIS7 rewriting.
#4

[eluser]Georgi Budinov[/eluser]
Neither am I aware of mod_rewriting on IIS7. Google that yourself - setting environment variables with mod_rewrite.
#5

[eluser]dallen33[/eluser]
I did and found out that IIS, within the GUI, can convert mod rewrite to IIS url rewrite. I'll have to give that a shot. Thanks again!
#6

[eluser]John_Betong[/eluser]
The way I do it is to use /_menu.php that sets $_SESSION['_MENU_'] then is redirected to index.php.

The variable index.php->$application has a default value that maybe be over-ridden if and only if $_SESSION['_MENU_'] is set.

http://johns-jokes.com/_menu.php
&nbsp;
&nbsp;
&nbsp;
#7

[eluser]dallen33[/eluser]
That's cool, but not really what I wanted. The url rewriting will work best.




Theme © iAndrew 2016 - Forum software by © MyBB