我在。net面板上托管了一个Laravel应用程序,如果安装在根目录下,它可以正常工作。但是我必须在根目录之后的两个子目录中使用它,即它安装在根/dir1/dir2/app中。现在,下面是我在网络上的当前代码。如果应用程序直接安装在根目录下,该配置文件可以正常工作:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Move to index.php">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=11" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
所以,目前,http://demo.example.com/dir1/dir2/index.php/login工作,但我需要它像http://demo.example.com/dir1/dir2/login,这是可能的吗?如果是,请尽可能多地解释你的答案。谢谢。
别介意!我想明白了。实际上,我的父目录是web。配置与子目录web冲突。配置文件,所以我在两个<rules>
标签之后添加了<clear />
,现在它工作得很好。看看下面的最终代码:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Move to index.php">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=11" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
希望这也能帮助到其他人。