2012-06-10 66 views
0

我一直在为此工作了几个小时。我正在尝试将Codeigniter框架放入Windows Azure网站。 PHP的伟大作品,但我似乎无法得到这个重写规则工作正确。这是我的web.config文件。Windows Azure重写规则导致HTTP错误500

<?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> 

当我将文件上传到Windows Azure的网站并运行它用HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request返回此时index.php我不知道该怎么做网页,做我需要做一些使用Windows Azure?我来自Apache背景,Windows IIS对我来说是新的。任何信息对我都有帮助,谢谢。

+0

'web.config'看起来不像PHP或Codeigniter;我认为它是Azure服务器系统的一部分,可能是某种IIS配置文件。 –

+0

你有没有尝试过他们在这里描述的内容:http://www.request-response.com/blog/PermaLink,guid,efe64356-5657-4e26-b145-8abed9feb6aa.aspx看起来像有一种方法可以得到一个更具描述性的错误网络。配置文件。微软网站上的另一个类似页面:http://blogs.msdn.com/b/rickandy/archive/2011/11/23/debugging-http-500-internal-server-error-with-windows-azure- sdk.aspx –

+0

这似乎是一个奇怪的重写。它看起来像将'/ foo'映射到'/ index.php/foo',这可能不存在。你确定你不想要像'index.php?path = {R:1}'这样的东西吗? – smarx

回答

1

根据您提供的信息作为我来自Apache背景,Windows IIS对我来说是新的,我相信你的问题与IIS配置有关,以支持URL Rewrite。 (如果您已经安装了URLRewrite并在Azure VM中配置,请告知我,我将删除此答案)

默认情况下,在Windows Azure中,IIS没有安装URLRewrite模块,因此无法执行任何URL ReWrite设置配置并将返回500错误。

您是否启用了对Azure虚拟机的RDP访问,以便您可以远程访问并查找登录到应用程序事件日志中的可能异常?如果您将RDP添加到Azure虚拟机并查找应用程序事件日志,您将看到解释URL重写模块的错误不可用。

首先,您需要创建一个启动任务以在您的Azure中安装URLRewrite模块。要了解有关Windows Azure启动任务的更多信息,请访问link

以下是关于如何在Windows Azure中启用URL重写的link。 (如果这是你的错误,我可以写详细信息关于如何获得URLRewrite在Windows Azure上工作)

0

我只是将ubuntu上的Apache移动到Azure网站上的IIS。根据下面的URL,重写模块似乎已经启用。我也使用Web平台安装程序在我的Windows 7上设置类似的环境(IIS Express 7.5),web.config也可以很好地工作。

“...... URL重写模块在云中总是处于启用状态可用。但是,你需要安装它使用它从你的本地开发环境......”

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

你的web.config似乎没问题,这与我的非常相似 - 删除url中的index.php。

请启用错误消息以输出IIS中的详细信息,以帮助您确定问题。我使用这些技巧来了解IIS如何查找我的文件。它是,和以下部分:

<?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> 

此外,请记住检查config.php中的base_url是否正确!

希望它有帮助!