2017-09-03 174 views
0

的WordPress的子目录我的控制之外的原因,我需要得到一个Laravel实例中运行的IIS里面10.我已经尽我的web.config配置<system.webServer><rewrite><rules />里面每一个可能的选项的WordPress的子目录,但我只能得到一个或另一个工作。如果我将重写规则留在WordPress中,Laravel不起作用(WordPress使用404响应),如果我禁用WordPress规则,Laravel可以正常工作,但显然WordPress不支持。配置Laravel作为IIS

这里是在站点的根目录(如WordPress的坐)的配置:它让我把一个嵌套的web.config中

<rewrite> 
    <rules>   
     <rule name="WordPress" patternSyntax="Wildcard"> 
      <match url="*" /> 
      <conditions> 
       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 

       <!-- Laravel App --> 
       <add input="{REQUEST_URI}" pattern="^/laravel" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php" /> 
     </rule> 
    </rules> 
</rewrite> 

由于采用了SO搜索,我碰到这个来(IIS Url Rewrite not working with nested WP installs)的子文件夹Laravel应用程序有以下:

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

奇怪的是,这些它几乎作品 - 只要我去site.com/laravel/public,所有相关工作的意见和一切戏剧很好ogether。我似乎无法取得URL的/ public,显然这是不可用的。

任何提示?我确定它很接近,但我无法弄清楚。

回答

0

明白了!我对Laravel还是个新手,所以这个对我来说并没有早日出现,但我有几个问题。我的根web.config文件是安装正确,但需要嵌套web.config对它有一个match url="*",像这样:

<rewrite> 
     <rules> 
      <clear /> 
       <rule name="Imported Rule 2" stopProcessing="true" patternSyntax="Wildcard"> 
        <match url="*" ignoreCase="false" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
        </conditions> 
        <action type="Rewrite" url="public/index.php/{R:1}" /> 
       </rule> 
     </rules> 

这项工作完成,他们都工作,但不包括/public的网址,我是得到一个404错误 - Laravel的404,特别是这意味着它的工作,只是不知道我在要求什么。总之,我看着自己的路线,并在他们面前添加了子目录,并突然全部工作!例如:

Route::get('/laravel/entities', '[email protected]'); 

我不是特别喜欢把根添加到所有路由中;然而,我们是一个非常独特的情况,所以这两个人甚至可以很好地相处,这一点令人印象深刻。