Phalcon 2.0 IIS 8.5

Hi,

Is it possible to have Phalcon running properly on IIS 8.5 ? I'm talking about URL Rewriting ?

What is the proper structure ? If a traduce .htaccess in Web.config file, do I need one at the root and one in the public file ?

Actualy, I have this in my root Web.config file :

<?xml version="1.0" encoding="utf-8"?>

<configuration>

<system.webServer>
    <rewrite>
    <rules>
        <rule name="Main Rule" stopProcessing="true">
        <match url="(.*)" />
        <action type="Rewrite" url="public/index.php?_url=/{R:1}" />
        </rule>
    </rules>
    </rewrite>
</system.webServer>

</configuration>

And this in my public/Web.config file :

<?xml version="1.0" encoding="utf-8"?>

<configuration>
<system.webServer>
    <rewrite>
    <rules>
        <rule name="Public Rule" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <serverVariables />
        <action type="Rewrite" url="index.php?_url=/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
        </rule>
    </rules>
    </rewrite>
</system.webServer>
</configuration>

I can't find out how to make this work.

Any help will be very appreciated.



145

Try this

root web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Main Rule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|woff|eot|svg|ttf" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="public/index.php?_url=/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

public/web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Public Rule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <serverVariables />
                    <action type="Rewrite" url="index.php?_url=/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


1.2k

Old but Gold!! I found a solution that works! These "web.configs" you presented here, ends in no correct path for static files, so you have to put manually path "public/" in each static paths you have. If you have a project and doest not mean to change any files because of IIS rules, try this solution:

root web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Static Rule" stopProcessing="true">
                    <match url="([\S]+[.](ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf))" ignoreCase="true" />
                    <action type="Rewrite" url="public/{R:1}" redirectType="Permanent" />
                </rule>
                <rule name="Root Rule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUESTFILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUESTFILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="public/index.php?_url=/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

public web.config


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Public Rule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUESTFILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUESTFILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?_url=/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

This works on any IIS since 7.5 with rewrite rule engine installed.