【问题标题】:app.yaml loads the css only for index.php file in CodeIgniterapp.yaml 仅为 CodeIgniter 中的 index.php 文件加载 css
【发布时间】:2015-10-17 22:30:19
【问题描述】:

我创建了一个代码点火器 PHP 项目,我需要将它部署到 Google 应用引擎。到目前为止,我已经配置了 app.yaml,如下所示

 application: the-new-test-project
version: 1
runtime: php55
api_version: 1
#threadsafe: yes

handlers:

- url: /css
  static_dir: application/views/css

- url: /images
  static_dir: application/views/images

- url: /js
  static_dir: application/views/js

- url: /fonts
  static_dir: application/views/fonts

- url: /.*
  script: index.php

使用 Google 应用引擎启动器运行我的项目后,它会很好地加载 index.php 页面以及应用的样式表。我的 index.php 文件中有一个名为“login”的链接,当我单击 login.php 页面时,该链接已加载。该代码如下:

<a href=<?php echo site_url('welcome/login'); ?>><i class="fa fa-lock"></i> Login</a>

我的欢迎控制器类如下所示:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

    public function index()
    {
        $this->load->view('index');
    }

        public function login()
        {
            $this->load->view('login');
        }
}

点击 index.php 页面上的“登录”链接后,它会加载登录页面但不应用样式表。我找不到问题所在。是 app.yaml 文件还是我在我的 php 文件中做了一些愚蠢的事情?请帮忙..

login.php 头部分如下:

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Login | E-Shopper</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <link href="css/prettyPhoto.css" rel="stylesheet">
    <link href="css/price-range.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="application/viewscss/main.css" rel="stylesheet">
    <link href="css/responsive.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->       
    <link rel="shortcut icon" href="images/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="images/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="images/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="images/ico/apple-touch-icon-57-precomposed.png">
</head><!--/head-->

【问题讨论】:

    标签: php codeigniter google-app-engine yaml


    【解决方案1】:

    使引用成为绝对的。即,而不是相对形式

    <link href="css/bootstrap.min.css" rel="stylesheet">
    

    使用

    <link href="/css/bootstrap.min.css" rel="stylesheet">
    

    Absolute vs relative URLs 中解释了差异(但请注意,您很可能在此处需要绝对形式,而不是该问题中推荐的相对形式)。

    【讨论】:

    • 哇!我怎么会错过那个小东西!问题解决了。谢谢
    猜你喜欢
    • 2015-02-23
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    相关资源
    最近更新 更多