app.yaml无法为我的index.php调用我的css文件

时间:2014-12-25 18:13:39

标签: google-app-engine app.yaml

我在php中创建了一个应用程序。文件夹“myapp-test-1”有一个名为index.php的文件和一个文件夹CSS,其中包含文件main.css,它是index.php的css文件。我正在尝试创建我的应用程序yaml文件以便上传我的项目在谷歌的应用程序引擎。这是我的app.yaml文件:

application: myapp-test-1  
version: 1
runtime: php
api_version: 1

handlers:

- url: /.*
  script: index.php

- url: /css
  static_dir: css

- url: /css/
  script: main.css

在浏览器中测试时,似乎index.php文件未满载。此外,index.php的css无效。

2 个答案:

答案 0 :(得分:5)

你需要

- url: /.*
  script: index.php

最后,因为如果你先拥有它,那么GAE将读取此文件的顺序是这个,然后是其他两个css。 .*旁边的正则表达式url表示所有网址都会显示index.php,因此最后这个网址将允许GAE首先读取css。您也不需要包含

- url: /css/
  script: main.css

如果您只想在index.php中加载css文件。

总的来说,它应该看起来像

application: myapp-test-1  
version: 1
runtime: php
api_version: 1

handlers:

- url: /css
  static_dir: css

- url: /.*
  script: index.php

答案 1 :(得分:0)

我相信你应该试着离开:
- 网址:/。*
script:path / index.php

并删除对css的两个引用。

从index.php中,确保使用正确的路径调用css文件。 最终如果你使用firefox,函数"检查元素"和控制台,将告诉你为什么你的文件没有加载......

祝你好运