Reputation: 31
I am currently running Windows Server 2012 R2 with IIS 8.5 and Phalcon 2.0.8 running on PHP 5.5.
I have a rewrite rule (using the basic .htaccess file that was imported from Phalcon) and the rewrites work fine. However, I have created a system variable in the the rewrite module called APPLICATION_ENV and it is attached to the rewrite with a value of staging.
If I view any page other than the main index of /public, then the value works -- staging is properly being pulled in. However, on the index, it doesn't apply the value. Why?
EDIT: Here is my current web.config file with everything in it.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?_url=/{R:1}" appendQueryString="true" />
<serverVariables>
<set name="APPLICATION_ENV" value="staging" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Upvotes: 3
Views: 554
Reputation: 929
Question (if I understood it correctly):
Why APPLICATION_ENV
is not set when I visit /public
?
Answer: The reason is that you have specified an exception:
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
This means that if a directory exists that matches the visited path, then no rewrite is to be performed. In your case you visit /public
and that's not the name of a controller, but of an actual directory. Therefore, its index file is served directly. The fact that it happens to be the same as the rewrite target is just a coincidence.
Upvotes: 1