简体   繁体   中英

IIS and Zend url rewrite

I am having issues with IIS. I can't seem to access www.site.com/controller/method
In my Zend project folder I have:

-public
-application
-...
-web.config

web.config content (to point to the public/ folder):

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 14" stopProcessing="true">
          <match url="!\.(js|gif|jpg|png|css|txt)$" ignoreCase="false" />
          <action type="Rewrite" url="public/index.php{R:1}" />
        </rule>
        <rule name="Imported Rule 15" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <action type="Rewrite" url="public/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

And in my public/ folder I have the following config (found in the Zend documentation):

web.config content:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^.*$" />
          <conditions logicalGrouping="MatchAny">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="false" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" ignoreCase="false" />
          </conditions>
          <action type="None" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^.*$" />
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

I think the main issue is rule 14 but I don't know why it doesn't work, and there is no impact if I delete the config from the public folder .

Any suggestions on how to fix this would be very helpful, this is my first deployment on a Windows server.

You need to change your Imported Rule 14 to be as follow:

<rule name="Imported Rule 14" stopProcessing="true">
  <match url="\.(js|gif|jpg|png|css|txt)$" negate="true" ignoreCase="false" />
  <action type="Rewrite" url="public/index.php{R:1}" />
</rule>

The option ! doesn't work in this case so use negate="true" instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM