Welcome Guest, Not a member yet? Register   Sign In
IIS 7.0, FastCGI and the new IIS 7 URL Rewriting
#1

[eluser]hooflung64[/eluser]
The new IIS URL_REWRITING ENGINE

I use Debian Etch, LIGHTTPD, POSTGRESQL/MYSQL and CI for the most part. However, here at work we use Windows 2k3 R2, IIS 6, ISAPI_REWRITE and PHP via CGI. We were going to use Hyper-V on Win2k8 and then run Debian VMs for each client site we run because sometimes they need different versions like databases.

One of the biggest fustrations I have on my live CI site on the current server which is just your plain Jane 2k3 IIS 6 install that the rewriting engine is that we have problems with multiple sites.

When I saw that IIS 7 now has a URL rewriting engine integrated into it if you grab the package it might actually allow me to run sites off one server and not worry about installing a small Debian VM for each system. Because we are also about to roll go to MS SQL for a proprietary system for registration I can get rid of our out dated MYSQL server and transition our clients to PostgreSQL (I need complete full text searching with custom dictionaries not just stop word omission.)

So... has anyone or will anyone share experience they might have had or what we might look for when we transition to Win2k8? We'll be getting our software in the next week so maybe in a few I can write up a worklog of our trials and tribulations (hey its microblah and they still don't get a lot of things.) Hopefully someone has used the URL Rewrite Mod or has some indepth knowledge of URL Rewriting past the 'copy off this forum, they have a working example' than I have at the moment.
#2

[eluser]hooflung64[/eluser]
Ok I have CI and URL Rewrite Module for IIS 7.0, Go Live working now with help from ruslany of the IIS.net forums.

This code can go into the web.conf file that each website in IIS 7 will have. I am using Windows 2k8 x64. The web server role was added after the update to the system. FastCGI was added and PHP 64bit from fusionxlan was used. Then the URL Rewrite for IIS 7.0, Go Live installed which adds the hotfix for the Request_URI server variable for PHP.

Code:
<rule name="MyRule">
      <match url="^(.*)$" />
       <conditions>
             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
             <add input="{HTTP_HOST}" pattern="(?:www\.)?myurl\.org" />
        </conditions>
        <action type="Rewrite" url="index.php/{R:1}" appendQueryString="false" />
</rule>

For development machines you can omit the third "add" tag and you can access your site via the IP and, if necessary, the port number. I found it unnecessary to use the "?" after index.php as I have to in IIS 6.

Code:
$config['base_url'] = "http://x.x.x.x:81/";


This is what I use for the site I am developing now. Obviously I use numbers ;-)

Code:
$config['uri_protocol'] = "PATH_INFO";

AUTO works too now although it ueses PATH_INFO. The others do not work with IIS 7 on my setup. QUERY_STRING was what I had to use with IIS 6.

You no longer need the extra rewrite rules for images and javascript because the matchType="isFile" negate="true" and matchType="isDirectory" negate="true" takes care of that.

Here are some screenshots of the process to do it via the GUI:

Step 1
Step 2
Step 3

So far I haven't had any URL rewriting issues now that I actually configured CI correctly (I had a brainfart and didn't remove the index.php from the $config['index_page'] setting in the config.php file.)

I hope this helps. I am a huge Linux fan. I have payed for Transgaming for 5 years and have a serious crush on Debian and Ubuntu. However, IIS 7 and Windows 2k8 in general has been winning me over for my 9-5 and now CI and IIS to me are a winning combination instead of the red headed stepchild. I don't feel like a warlock at work doing black magic that IIS 6 had me doing for Ruby on Rails and CI to work properly.
#3

[eluser]Fatih[/eluser]
Please note that!

If you want to use query_string option you must set TRUE to appendQueryString variable.

Code:
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
#4

[eluser]Dsyfa[/eluser]
Hi,

I've tried the above rules but I still get the same error.

Code:
Warning: require(system/codeigniter/Common.php) [function.require]: failed to open stream: No such file or directory in C:\HostingSpaces\raihaniq\raihaniqbal.com\wwwroot\system\codeigniter\CodeIgniter.php on line 38

Warning: require(system/codeigniter/Common.php) [function.require]: failed to open stream: No such file or directory in C:\HostingSpaces\raihaniq\raihaniqbal.com\wwwroot\system\codeigniter\CodeIgniter.php on line 38

Fatal error: require() [function.require]: Failed opening required 'system/codeigniter/Common.php' (include_path='.;C:\php5\pear') in C:\HostingSpaces\raihaniq\raihaniqbal.com\wwwroot\system\codeigniter\CodeIgniter.php on line 38

Later I used the Import Rule tool in IIS Manager.

This is my complete web.config file:

Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
            </files>
        </defaultDocument>
        <handlers accessPolicy="Read, Execute, Script" />
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Where am I going wrong?

Any sort of help would be greatly appreciated.

Thanks
#5

[eluser]Maglok[/eluser]
We kind of just bought an addon that allows us to read .htaccess files. That web.config is just seriously annoying us.

CI is giving me some issues on an environment like that as well. Or better said: IIS7 is not reacting as we predict it should.

Nice info this. Smile
#6

[eluser]Rolly1971[/eluser]
hi there, i use IIS7 with CI 1.7.2 and 2.0 and the built in URL Rewrite engine and it works without fail.

here is my web.config i am using:

Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rewrite to index.php">
                    <match url="index.php|robots.txt|images|test.php" />
                    <action type="None" />
                </rule>
                <rule name="Rewrite CI Index">
                    <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>
#7

[eluser]furball[/eluser]
[quote author="Rolly1971" date="1287811698"]hi there, i use IIS7 with CI 1.7.2 and 2.0 and the built in URL Rewrite engine and it works without fail.

here is my web.config i am using:

Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rewrite to index.php">
                    <match url="index.php|robots.txt|images|test.php" />
                    <action type="None" />
                </rule>
                <rule name="Rewrite CI Index">
                    <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>
[/quote]

Cool, this works. But i have a little problem here, i have /forum directory for my vbulletin installation.
How do I ignore /forum so it won't rewrite to /index.php/forum ?

edit: got it, just need to enable Stop processing subsequent and add forum to
Code:
<match url="index.php|robots.txt|images|test.php|forum " />
Thanks!
#8

[eluser]Dhanapal MCA[/eluser]
where to copy web.config file in codeigniter..
#9

[eluser]ci_user[/eluser]
URL rewrite still not working in IIS7. Driving me nuts! I've tried everything mentioned here but no joy! I do have my application folder above the webroot. I moved it into the webroot thinking that might be the problem, but still no joy. For security I would prefer to keep the app folder above the webroot. Does anybody know if this requires anything special to make the URL rewrite work with the app above the webroot? Thanks!

[quote author="Rolly1971" date="1287797298"]hi there, i use IIS7 with CI 1.7.2 and 2.0 and the built in URL Rewrite engine and it works without fail.

here is my web.config i am using:

Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rewrite to index.php">
                    <match url="index.php|robots.txt|images|test.php" />
                    <action type="None" />
                </rule>
                <rule name="Rewrite CI Index">
                    <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>
[/quote]
#10

[eluser]ci_user[/eluser]
I know this is an old post but I just realized I never put up my solution... RESTART the IIS URL Rewrite extension. Do'h!

[quote author="ci_user" date="1335537147"]URL rewrite still not working in IIS7. Driving me nuts! I've tried everything mentioned here but no joy! I do have my application folder above the webroot. I moved it into the webroot thinking that might be the problem, but still no joy. For security I would prefer to keep the app folder above the webroot. Does anybody know if this requires anything special to make the URL rewrite work with the app above the webroot? Thanks!

[quote author="Rolly1971" date="1287797298"]hi there, i use IIS7 with CI 1.7.2 and 2.0 and the built in URL Rewrite engine and it works without fail.

here is my web.config i am using:

Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rewrite to index.php">
                    <match url="index.php|robots.txt|images|test.php" />
                    <action type="None" />
                </rule>
                <rule name="Rewrite CI Index">
                    <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>
[/quote][/quote]




Theme © iAndrew 2016 - Forum software by © MyBB