Welcome Guest, Not a member yet? Register   Sign In
Anyone familiar with IIS Rewrite?
#1

[eluser]dallen33[/eluser]
I want URLs like this:

http://website.com/application1
http://website.com/application2

To re-direct to the proper application folder. My folder structure for CI2 is as follows:

index.php
- ci_apps
-- application1
-- application2
- ci_system

I'm guessing I need to use URL rewrite to do this, but I have no idea how to accomplish this. Right now, my web.config file looks like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
    
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="iisstart.htm" />
            </files>
        </defaultDocument>

        <rewrite>
            <rules>
                <rule name="ci_rule_01" stopProcessing="true">
                    <match url="(index.php|robots.txt|sitemap.xml|info.php|favicon.ico|testing|ci_apps)" />
                </rule>
                <rule name="ci_rule_02">
                    <match url=".*" />
                    <action type="Rewrite" url="index.php/{r:0}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Someone in another thread suggested I use this:

Code:
RewriteEngine on

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

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

But, in all honesty, I know nothing about modRewrite that would allow me to decipher that and get it working with IIS URL Rewrite.

Any ideas how I can do this?
#2

[eluser]Rolly1971[/eluser]
hey matey, not sure if you found a solution yet, but a few weeks ago i went into iis and played around with the url rewrite, and using the oddly this time useful msdn i found what i was looking for to get it working,

this is my web.config file for the rewrite rules and it works a beauty.

Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rewrite CI index.php">
                    <match url="index.php|robots.txt|images|test.php" />
                    <action type="None" />
                </rule>
                <rule name="Rewrite CI Negate">
                    <match url=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
#3

[eluser]dallen33[/eluser]
That's cool and all, but it's essentially what I posted from my web.config file. But it did get me thinking. Maybe what I'm wanting to do is too complicated.

Do you know if this is possible? Let's say I create an index.php for each application I have, but renaming index.php to the name of the app. Like http://website.com/application1.php, http://website.com/application2.php. That would work, but would there be a way I could get URL Rewrite to allow me to get rid of .php and have it still load the PHP file instead of looking for a folder?
#4

[eluser]Rolly1971[/eluser]
lol guess i should have read your post a bit better.

well not 100% sure on this one.

i will do some digging to see what i can find out.
#5

[eluser]dallen33[/eluser]
No problem, anything helps!

At this point, I'm trying to get .php files to load if the extension isn't typed in. But it's causing me issues because of this rule:

Code:
<rule name="ci_rule_02">
                    <match url="(.*)" />
                    <action type="Rewrite" url="index.php/{r:0}" appendQueryString="false" />
                </rule>
#6

[eluser]Clooner[/eluser]
Maybe this thread has some useful information about it. It's also IIS but uses a different rewriting mechanism! http://ellislab.com/forums/viewthread/111164/




Theme © iAndrew 2016 - Forum software by © MyBB