dpjtn48868 2014-01-25 19:55
浏览 58
已采纳

在Laravel中,不同的网址丢失了样式

I use Laravel in my web project. I have specified these routes for unauthenticated users.

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");
    }));
});

If I access / my page looks correct. If I try to accesss /account/login, I don't get the stylesheets. I think this has to do with the rewrite. I use IIS on Windows Server 2012 and I have this kind of web.config file in the public folder.

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

I have two projects. In one of them this works but in the other it doesn't. What might be wrong with it?

  • 写回答

1条回答 默认 最新

  • doutangxi2144 2014-01-25 20:11
    关注

    Use the URL::asset() to link to the stylesheet. Because in / it links to (for example) example.com/css/style.css And if you're in /account/login, it will look for the stylesheet in example.com/account/login/css/style.css

    I use <link rel="stylesheet" href="{{ URL::asset('css/style.min.css') }}"/> in my master blade template.

    Hope it helps

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号