简体   繁体   中英

Windows Azure Rewrite Rule Causes HTTP Error 500

I've been working on this for a few hours now. I am trying to place Codeigniter framework into a Windows Azure website. PHP works great however I can't seem to get this rewrite rule to work right. This is my web.config file.

<?xml version="1.0"?>

    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Rule" 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" />
                <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>

When I upload the file to the Windows Azure website and run the page with the index.php it returns with a HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request At this point I am not sure what to do, do I need to do something with Windows Azure? I am coming from an Apache background, Windows IIS is new to me. Any information is helpful to me thank you.

Based on the information you provided as I am coming from an Apache background, Windows IIS is new to me , I am sure that your problem is related with IIS configuration to support URL Rewrite. (IF you have already installed URLRewrite and configured in Azure VM let me know and I will delete this answer)

By default in Windows Azure, IIS does not have URLRewrite module installed so it can not perform any of the URL ReWrite setting configured and will return 500 error.

Have you enabled RDP access to your Azure VM so you can remote into and that look for possible exception logged in Application event log? If you RDP to your Azure VM and look for Application event log you will see an error explaining URL Rewrite modules is not available.

First you need to create a Start up Task to install URLRewrite module in your Azure. To learn more about Windows Azure Startup task visit this link .

Here is a link on how to enabled URL Rewrite in Windows Azure. (if this is your error, I can write details info on how to get URLRewrite working on Windows Azure)

I just move Apache on ubuntu to IIS on Azure Web Site. According to the below url, The rewrite module seems to be enabled already. I also use Web Platform Installer to setup an similar environment (IIS express 7.5) on my Windows 7, the web.config works perfectly, too.

"...The URL Rewrite module is always enabled and available in the cloud. However, you will need to install it to use it from your local development environment..."

http://msdn.microsoft.com/en-us/library/windowsazure/dd573358.aspx

Your web.config seems okay which is very similar to mine - to remove the index.php in url.

Please enable the error message to output the detail from IIS which shall help you to identify the problem. I use the tricks to find out how IIS looks for my files. It is , , and the section as below:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <system.webServer>

        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true"/>

        <rewrite>
        <rules>
            <rule name="RuleRemoveIndex" 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}" appendQueryString="true"/>
            </rule>
        </rules>
        </rewrite>

    </system.webServer>

    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>

</configuration>

Also, please remember to check the base_url in config.php is correct!

Wish it helps!

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