简体   繁体   English

无法控制对Google App Engine上的静态文件的请求

[英]Unable to control requests for static files on Google App Engine

My simple GAE app is not redirecting to the /static directory for requests when url is multiple levels. 当url为多个级别时,我简单的GAE应用程序不会将请求重定向到/ static目录。

Dir structure: 目录结构:

 /app/static/css/main.css

App: 应用程式:

I have two handlers one for /app and one for /app/new 我有两个处理程序,一个用于/ app,一个用于/ app / new

app.yaml: app.yaml:

handlers:

- url: /static
  static_dir: static

- url: /app/static/(.*)
  static_dir: static\1

- url: /app/.*
  script: app.py
  login: required

HTML: HTML:

Description: When page is loaded from /app HTTP request for main.css is successful 说明:当从/ app加载页面时,对main.css的HTTP请求成功

 GET /static/css/main.css

But when page is loaded from /app/new I see the following request: 但是当从/ app / new加载页面时,我看到以下请求:

GET /app/static/css/main.cs

That's when I tried adding the /app/static/(.*) in the app.yaml but it is not having any effect. 那是当我尝试在app.yaml中添加/app/static/(.*)时,但没有任何效果。

In HTML an internal link starting with "/" is an absolute link, a link starting without a "/" is a relative link. 在HTML中,以“ /”开头的内部链接是绝对链接,不以“ /”开头的内部链接是相对链接。 So if you are requesting: 因此,如果您要求:

/app / app

and have a relative link: 并有一个相对链接:

static/css/main.css 静态/ CSS / main.css

the request becomes: 该请求变为:

/static/css/main.css /static/css/main.css

the relative link uses the "/" in "/app" because the "app" part is considered to be the page and the "/" is considered to be the directory. 相对链接在“ / app”中使用“ /”,因为“ app”部分被视为页面,而“ /”被视为目录。

If you are requesting: 如果您要求:

/app/new / app /新

Your request becomes: 您的请求将变为:

/app/static/css/main.css /app/static/css/main.css

the relative link uses the "/app/" because "/app/" is considered the directory and "new" is considered the page. 相对链接使用“ / app /”,因为“ / app /”被视为目录,而“ new”被视为页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM