2014-01-25 20 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') }}"/>

希望它有幫助