2014-01-25 16 views
0

我在我的web项目中使用Laravel。我为未经验证的用户指定了这些路由。Laravel在不同url中丢失的样式

Route::group(array("before" => "guest"), function() { 
    // Show the login page for the user 
    Route::get("/", array("as" => "homepage", function() { 
     return View::make("unauthenticated.login"); 
    })); 

    Route::get("/account/login", array("as" => "account-login-get", function() { 
     return View::make("unauthenticated.login"); 
    })); 
}); 

如果我访问/我的页面看起来正确。如果我尝试访问/account/login,我不会收到样式表。我认为这与重写有关。我在Windows Server 2012上使用IIS,并且在公用文件夹中有这种web.config文件。

<?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> 
    </system.webServer> 
</configuration> 

我有两个项目。在其中一个这样的工作,但在另一个没有。它可能有什么问题?

回答

1

使用URL::asset()链接到样式表。 由于/它链接到(例如)example.com/css/style.css 如果你在/account/login的时候,它会寻找样式表中example.com/account/login/css/style.css

我在主基片模板使用<link rel="stylesheet" href="{{ URL::asset('css/style.min.css') }}"/>

希望它有帮助