另一个应用程序的Azurewebsite django URL重写 [英] Azurewebsite django URL rewrite for another application

查看:64
本文介绍了另一个应用程序的Azurewebsite django URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在主要运行Django的Azure网站中安装了wordpress.我已经在应用程序设置中将应用程序设置为/blog到/site/wwwroot/blog.

I've installed wordpress in Azurewebsites which is primarily running Django. I've set up an application as /blog to /site/wwwroot/blog in application setting.

但是web.config没有提供网址www.example.com/blog,而是抛出404错误.

But web.config is not serving the url www.example.com/blog instead it's throwing 404 error.

这是web.config,您能否建议如何禁用www.example.com/blog的重写

Here's the web.config, could you suggest how to disable rewrite for www.example.com/blog

<?xml version="1.0"?>
<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="WSGI_ALT_VIRTUALENV_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
    <add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS" value="D:\home\site\wwwroot\env\Scripts\python.exe" />
    <add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_venv_handler()" />
    <add key="PYTHONPATH" value="D:\home\site\wwwroot" />

    <!--
    <add key="WSGI_PTVSD_SECRET" value="" />
    -->
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <!-- Required for websockets. -->
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="Python340_via_FastCGI" />
      <add name="Python FastCGI" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\Python34\python.exe|D:\Python34\Scripts\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
      <!-- Uncomment the following handler to enable remote debugging. -->
      <!--
      <add name="ptvsd" path="ptvsd" verb="*" resourceType="Unspecified" type="Microsoft.PythonTools.Debugger.WebSocketProxy, Microsoft.PythonTools.WebRole"/>
      -->
      <!-- <clear/>
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
      -->
    </handlers>
    <rewrite>
      <rules>
        <!-- Uncomment the following rule to enable remote debugging. -->
        <!--
        <rule name="ptvsd" enabled="true" stopProcessing="true">
          <match url="^ptvsd(/.*)?$"/>
        </rule>
        -->
        <rule name="Static Files" stopProcessing="true">
          <conditions>
            <add input="true" pattern="false" />
          </conditions>
        </rule>
        <rule name="Configure Python" stopProcessing="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
          </conditions>
          <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
    <staticContent>
           <clientCache cacheControlMaxAge ="7.00:00:00" cacheControlMode="UseMaxAge" />
    </staticContent>
  </system.webServer>
</configuration>

推荐答案

根据您的描述,建议您尝试在规则中添加不匹配的条件.

According to your description, I suggest you could try to add a not match condition in the rules.

如果url的目标是blob文件夹,则不会被重写.

If the url's target is blob folder, then it will not be rewrite.

更多详细信息,您可以参考以下配置.

More details, you could refer to below config.

<rule name="Configure Python" stopProcessing="true">
  <match url="(.*)" ignoreCase="false" />
  <conditions>
    <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
     <add input="{URL}" pattern="^/blog/.*" ignoreCase="true" negate="true" />
  </conditions>
  <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
</rule>

结果如下:

这篇关于另一个应用程序的Azurewebsite django URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆