CSS文件未通过Google

CSS文件未通过Google

本文介绍了CSS文件未通过Google App Engine和运行时php72加载到PHP Laravel应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用标准配置(运行时:php72)在Google App Engine上运行带有其自己的CSS文件的Laravel 5.8.x应用程序的标准安装.显示页面,但未加载CSS文件public/css/main.css.浏览器中出现404错误.

I try to run a standard installation of a Laravel 5.8.x application with its own CSS file on the Google App Engine with standard configuration (runtime: php72).The page is displayed, but the CSS file public/css/main.css is not loaded. There is a 404 error in the browser.

这是我的app.yaml代码:

This is my app.yaml code:

runtime: php72
service: default

env_variables:
  APP_KEY: xxxxx
  APP_STORAGE: /tmp
  VIEW_COMPILED_PATH: /tmp
  APP_ENV: production
  APP_DEBUG: false
  CACHE_DRIVER: database
  SESSION_DRIVER: database
  ...

我将这行代码添加到了welcome.blade.php的头部.

I added this line to welcome.blade.php into the head.

<link rel="stylesheet" href="/css/main.css">

我该如何解决这个问题?

How can I solve this problem?

推荐答案

我必须在env_variables之前将以下内容添加到您的app.yaml文件中:

I had to add the following to your app.yaml file before env_variables:

handlers:
- url: /(.*\.(gif|png|jpg|css|js))$
  static_files: public/\1
  upload: public/.*\.(gif|png|jpg|css|js)$

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto

然后它起作用

这篇关于CSS文件未通过Google App Engine和运行时php72加载到PHP Laravel应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 01:11