从iis服务器中的Subfolder执行Php(MVC)项目

时间:2015-08-08 06:07:00

标签: php azure iis url-rewriting web-config

我有一个在Azure服务器(IIS服务器)中托管的php网站,我想为这个网站设置一个测试环境http://example.com/test1/,但问题是现有的重写规则处理' test1&# 39;作为参数(控制器名称)而不是文件夹名称

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

这是我目前正在使用的web.config文件中的重写规则。 example.com/index/login工作正常但是example.com/test1/index/login会返回错误&#39; application / default / controller / test1.php&#39;在页面中,代码仍在从根文件夹执行。请让我知道如何解决这个问题。

1 个答案:

答案 0 :(得分:1)

如果您想设置测试环境,我建议您为您的网络应用设置一个暂存环境,有关详细信息,请参阅https://azure.microsoft.com/en-gb/documentation/articles/web-sites-staged-publishing/。如果您想为某个目的为您的Web应用程序设置虚拟目录,请考虑在您的Azure门户中进行配置,这很容易,您可以配置如下截图: enter image description here

然后在此&#34;测试&#34;中部署您的应用程序夹。希望这会有所帮助。