gpt4 book ai didi

django - Azurewebsite django URL 重写另一个应用程序

转载 作者:行者123 更新时间:2023-12-03 05:53:07 30 4
gpt4 key购买 nike

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

但是 web.config 不提供 URL www.example.com/blog,而是抛出 404 错误。

这是 web.config,您能否建议如何禁用 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>

最佳答案

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

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

更多详细信息,您可以引用下面的配置。

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

结果如下:

enter image description here

关于django - Azurewebsite django URL 重写另一个应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45343655/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com