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

use*_*321 0 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
Run Code Online (Sandbox Code Playgroud)

在浏览器中测试时,似乎index.php文件未满载.此外,index.php的css不起作用.

Leo*_*Han 5

你需要拥有

- url: /.*
  script: index.php
Run Code Online (Sandbox Code Playgroud)

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

- url: /css/
  script: main.css
Run Code Online (Sandbox Code Playgroud)

如果你只是要在index.php中加载css文件.

总的来说,它看起来应该是这样的

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

handlers:

- url: /css
  static_dir: css

- url: /.*
  script: index.php
Run Code Online (Sandbox Code Playgroud)