IIS上的域正在覆盖子目录

问题描述

我在IIS中有一个站点,可以说 www.example.com Laravel应用程序),而我的子目录是 www.example.com/subdirectory Django应用程序),当我访问 /子目录时,域将覆盖我的子目录,并且我会得到404页面的Laravel,

我试图在域的web.config中制定规则,但是我没有得到结果,而且我不知道该怎么做

所以,这是我在main.settings(Django)中的配置

USE_X_FORWARDED_HOST = True
FORCE_SCRIPT_NAME = '/subdirectory/'
SESSION_COOKIE_PATH = '/subdirectory/'
LOGIN_REDIRECT_URL='/subdirectory/'
LOGOUT_REDIRECT_URL='/subdirectory/'
VIRTUAL_DIRECTORY = "subdirectory/"   
ALLOWED_HOSTS = ['example.com','localhost','wwww.example.com'] 

和我在main.urls中的urlpatterns

urlpatterns = [
    path(f'{settings.VIRTUAL_DIRECTORY}admin/',admin.site.urls),# path('password_change/',views.password_change,name='password_change'),path(f'{settings.VIRTUAL_DIRECTORY}',include('django.contrib.auth.urls')),views.index,name='index'),path(f'{settings.VIRTUAL_DIRECTORY}aluno/',include('aluno.urls')),path(f'{settings.VIRTUAL_DIRECTORY}empresa/',include('empresa.urls')),]

和Laravel上的web.config

<configuration>
    <system.webServer>
        <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
          <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
          <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
          </dynamicTypes>
          <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="image/*" enabled="true" />
            <add mimeType="*/*" enabled="false" />
          </staticTypes>
        </httpCompression>
        <urlCompression doStaticCompression="true" doDynamicCompression="true" />
    
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="1048576000" />
            </requestFiltering>
        </security>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="default.aspx" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <clear />
                
                
                <!-- INICIO - TO WWW  -->
                <rule name="Redirect to www" enabled="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^example.com$" />
                    </conditions>
                    <action type="Redirect" url="https://www.example.com/{R:0}" />
                </rule>
                <!-- FIM - TO WWW  -->
                
                <!-- INICIO - HTTP to HTTPS  -->
                <rule name="HTTP to HTTPS" enabled="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{SERVER_PORT_SECURE}" pattern="^0$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
                </rule>
                <!-- FIM - HTTP to HTTPS -->                

                
                
                <!-- FIM - LINKS REDIRECIONAMENTOS  -->

                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)/$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Redirect" url="/{R:1}" redirectType="Permanent" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>

                 <rule name="subdirectory" stopProcessing="true">
              <match url="^subdirectory(.*)" />
              <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
              </conditions>
              <action type="None" logRewrittenUrl="true" />
          </rule>
            </rules>
        </rewrite>
        <handlers>
            <remove name="PHP53_via_FastCGI" />
        </handlers>
        <staticContent>
            <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
        </staticContent>
        <caching enabled="true" enableKernelCache="true" />
    </system.webServer>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
        <customErrors mode="Off" />     
    </system.web>
</configuration>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...