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

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

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路