Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
[IIS][Azure]Configure FuelPHP
  • Hi,
    I'va a problem to configure FuelPHP with Windows Azure. Azure use IIS server and i can configure this with Web.config in root directory. But, to launch FuelPHP, i want to go in public subDirectory. Web.config :
    <configuration>
    <system.diagnostics>
    <trace>
    <listeners>
    <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
    <filter type="" />
    </add>
    </listeners>
    </trace>
    </system.diagnostics>
    <appSettings>
    <add key="EMULATED" value="true" />
    </appSettings>
    <system.webServer>
    <defaultDocument>
    <files>
    <clear />
    <add value="index.php" />
    <add value="index.htm" />
    <add value="index.html" />
    </files>
    </defaultDocument>
    <rewrite>
    <rules>
    <rule name="Règle 2 importée" stopProcessing="true">
    <match url="^(/)?$" ignoreCase="false" />
    <action type="Rewrite" url="/public/index.php/{R:1}" />
    </rule>
    <rule name="Règle 1 importée" stopProcessing="true">
    <match url="^(.*)$" ignoreCase="false" />
    <conditions>
    <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="/public/index.php/{R:1}" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration> The code works fine for PHP rewriting but, if i can access to html, jpeg, ... it's only possible if I enter /public/myfile.html Have you a good configuration file for FuelPHP on IIS server? Thanks in advance.
  • FuelPHP is designed in such a way that the public folder should be your webserver document root. This way there is no "/public" visible for users, and you don't have this issue. This is done so that all your code is not accessable via the URL. Last time I looked you couldn't change the document root in Azure to a subfolder. If that is still the case, you are forced to make your code visible (so make sure they are all secure!). Just copy everything in the public folder one level up (so the files are in the docroot), and remove the now empty "public folder. You can then change the rewrite to only "index.php/{R:1}".
  • Ok, i've second problem, I have create a constant redirection tu /public folder, it work fine and System files are protected. I've create a Web.config in public folder and add FuelPHP rules converted for IIS with IIS Manager. But php rewrite rules does'nt works directly. If i enter localhost/module/controller/action => does'nt work
    If i enter localhost/public/module/controller/action => it works In error, i see the public redirect work but, other rules does'nt work in this case Web config file in root folder :
    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      [url=http://go.microsoft.com/fwlink/?LinkId=169433]http://go.microsoft.com/fwlink/?LinkId=169433[/url]
      -->
    <configuration>
      <system.diagnostics>
       <trace>
          <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
              <filter type="" />
            </add>
          </listeners>
        </trace>
      </system.diagnostics>
      <appSettings>
        <add key="EMULATED" value="true" />
      </appSettings>
      <system.webServer>
          <httpErrors errorMode="Detailed"/>
          <defaultDocument>
          <files>
            <clear />
            <add value="index.php" />
            <add value="index.htm" />
            <add value="index.html" />
          </files>
        </defaultDocument>
          <rewrite>
              <rules>
                  <rule name="Redir Subdir" stopProcessing="true">
                      <match url="(.*)" ignoreCase="false" />
                      <conditions>
                          <add input="{URL}" pattern="^/public" ignoreCase="false" negate="true" />
                      </conditions>
                      <action type="Rewrite" url="/public/{R:1}" appendQueryString="true" />
                  </rule>
              </rules>
          </rewrite>
      </system.webServer>
    </configuration>
    

    Web.config in public folder :
    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      [url=http://go.microsoft.com/fwlink/?LinkId=169433]http://go.microsoft.com/fwlink/?LinkId=169433[/url]
      -->
    <configuration>
        <system.diagnostics>
            <trace>
                <listeners>
                    <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
                        <filter type="" />
                    </add>
                </listeners>
            </trace>
        </system.diagnostics>
        <appSettings>
            <add key="EMULATED" value="true" />
        </appSettings>
        <system.webServer>
            <httpErrors errorMode="Detailed"/>
            <defaultDocument>
                <files>
                    <clear />
                    <add value="index.php" />
                    <add value="index.htm" />
                    <add value="index.html" />
                </files>
            </defaultDocument>
            <rewrite>
                <rules>
                    <rule name="RegleScript" stopProcessing="true">
                        <match url="^(/)?$" ignoreCase="false" />
                        <action type="Rewrite" url="index.php/{R:1}" />
                    </rule>
                    <rule name="RegleFichier" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions>
                            <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>
    

    Thanks in advance.
  • I can't be of more assistance, I'm not a Windows user, and I've never used Azure.
  • I found the solution. In the Web.config in the root, i created new Rule an pass the fisrt in stopProcessing false and it works
    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      [url=http://go.microsoft.com/fwlink/?LinkId=169433]http://go.microsoft.com/fwlink/?LinkId=169433[/url]
      -->
    <configuration>
      <system.diagnostics>
       <trace>
          <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
              <filter type="" />
            </add>
          </listeners>
        </trace>
      </system.diagnostics>
      <appSettings>
        <add key="EMULATED" value="true" />
      </appSettings>
      <system.webServer>
          <httpErrors errorMode="Detailed"/>
          <defaultDocument>
          <files>
            <clear />
            <add value="index.php" />
            <add value="index.htm" />
            <add value="index.html" />
          </files>
        </defaultDocument>
          <rewrite>
              <rules>
    
                  <rule name="Redir Subdir" stopProcessing="false">
                      <match url="(.*)" ignoreCase="false" />
                      <conditions>
                          <add input="{URL}" pattern="^/public" ignoreCase="false" negate="true" />
                      </conditions>
                      <action type="Rewrite" url="/public/{R:1}" appendQueryString="false" />
                  </rule>
    
                  <rule name="RegleFichierPublic" stopProcessing="true">
                      <match url="^\/public\/(.*)$" ignoreCase="false" />
                      <conditions>
                          <add input="{URL}" pattern="^/public" ignoreCase="false" negate="true" />
                          <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="/public/index.php/{R:1}" appendQueryString="true" />
                  </rule>
              </rules>
          </rewrite>
      </system.webServer>
    </configuration>
    
  • Great! Can you make a wrap-up of what exactly is needed to get FuelPHP working on Azure (which config examples), so we can add this to the documentation?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion