handlers:# All URLs beginning with /stylesheets are treated as paths to# static files in the stylesheets/ directory.-url:/stylesheetsstatic_dir:stylesheets# ...
handlers:# All URLs ending in .gif .png or .jpg are treated as paths to# static files in the static/ directory. The URL pattern is a# regular expression, with a grouping that is inserted into the# path to the file.-url:/(.*\.(gif|png|jpg))$static_files:static/\1upload:static/.*\.(gif|png|jpg)$# ...
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-20。"],[[["\u003cp\u003eThe \u003ccode\u003eapp.yaml\u003c/code\u003e file is essential for configuring App Engine applications, defining settings, URL paths, request handlers, and static files, with each service having its own configuration file.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eregion ID\u003c/code\u003e is a code assigned by Google based on the selected region during app creation and is included in App Engine URLs for applications made after February 2020.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eapp.yaml\u003c/code\u003e uses YAML format, allows comments with \u003ccode\u003e#\u003c/code\u003e, and utilizes POSIX extended regular expressions for URL and file path patterns.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ehandlers\u003c/code\u003e section in \u003ccode\u003eapp.yaml\u003c/code\u003e defines how the application handles different URLs, specifying elements like \u003ccode\u003escript\u003c/code\u003e, \u003ccode\u003estatic_files\u003c/code\u003e, \u003ccode\u003eurl\u003c/code\u003e, \u003ccode\u003esecure\u003c/code\u003e, \u003ccode\u003eredirect_http_response_code\u003c/code\u003e and \u003ccode\u003ehttp_headers\u003c/code\u003e, among other attributes.\u003c/p\u003e\n"],["\u003cp\u003eScaling elements such as \u003ccode\u003eautomatic_scaling\u003c/code\u003e, \u003ccode\u003ebasic_scaling\u003c/code\u003e, and \u003ccode\u003emanual_scaling\u003c/code\u003e control how App Engine manages instance counts based on traffic and resource usage, affecting performance and cost.\u003c/p\u003e\n"]]],[],null,["# App Engine app.yaml reference\n\n### Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/php/how-requests-are-routed#region-id). \nOK\n\n\u003cbr /\u003e\n\nYou configure your App Engine app's settings in the `app.yaml`\nfile.\n\nThis file specifies how URL paths correspond to request handlers and\nstatic files.\n\nThe `app.yaml` file also contains information about your\napp's code, such as the runtime and the latest version\nidentifier.\n\nEach [service](/appengine/docs/legacy/standard/php/an-overview-of-app-engine#services)\nin your app has its own `app.yaml` file, which acts as a descriptor for its\ndeployment. You must first create the `app.yaml` file for the `default` service\nbefore you can create and deploy `app.yaml` files for additional services within\nyour app.\n\n\u003cbr /\u003e\n\nDirectory structure\n-------------------\n\nTo learn more about structuring multiple services in your app, see [Structuring Web Services in App Engine](/appengine/docs/legacy/standard/php/configuration-files).\n\n\u003cbr /\u003e\n\nExample\n-------\n\nThe following is an example of an `app.yaml` file for a PHP 5\napplication:\n\n\u003cbr /\u003e\n\n```yaml\nruntime: php55\napi_version: 1\n\nhandlers:\n# Serve images as static resources.\n- url: /(.+\\.(gif|png|jpg))$\n static_files: \\1\n upload: .+\\.(gif|png|jpg)$\n application_readable: true\n\n# Serve php scripts.\n- url: /(.+\\.php)$\n script: \\1\n```\n\nThe above example will serve files with extension of `gif`, `png`, or `jpg` as\nstatic resources. The files have been configured to be readable by the\napplication code at runtime.\n\nThe example will also serve all PHP scripts. You can restrict the script handler\nto root-level scripts by using the `url: /([^/]+\\.php)` expression. Existing\napplications might find it useful to [simulate Apache mod_rewrite `$_GET['q']`\nrouting](/appengine/docs/legacy/standard/php/config/mod_rewrite).\n\nA more extensive `app.yaml` configuration is provided below: \n\n```yaml\nruntime: php55\napi_version: 1\n\nhandlers:\n- url: /\n script: home.php\n\n- url: /index\\.html\n script: home.php\n\n- url: /stylesheets\n static_dir: stylesheets\n\n- url: /(.*\\.(gif|png|jpg))$\n static_files: static/\\1\n upload: static/.*\\.(gif|png|jpg)$\n\n- url: /admin/.*\n script: admin.php\n login: admin\n\n- url: /.*\n script: not_found.php\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSyntax\n------\n\nThe syntax of `app.yaml` is the [YAML format](http://www.yaml.org/).\n\nThe YAML format supports comments. A line that begins with a pound (`#`)\ncharacter is ignored: \n\n # This is a comment.\n\nURL and file path patterns use [POSIX extended regular expression\nsyntax](https://wikipedia.org/wiki/Regular_expression), excluding collating\nelements and collation classes. Back-references to grouped matches (e.g. `\\1`)\nare supported, as are these Perl extensions: `\\w \\W \\s \\S \\d \\D`.\n\n### Runtime and app elements\n\n### Handlers element\n\nThe `handlers` element is a required element in the\n`app.yaml` configuration file. The element provides a list of URL\npatterns and descriptions of how they should be handled. App Engine can\nhandle URLs by executing application code, or by serving static files uploaded\nwith the code, such as images, CSS, or JavaScript.\n\nPatterns are evaluated in the order they appear in the `app.yaml` file, from\ntop to bottom. The first mapping whose pattern matches the URL is the one used\nto handle the request.\n\nThe following table lists the subelements of the `handlers` element that control\nthe behavior for scripts, static files,\nstatic directories, and other settings.\n\n### Scaling elements\n\nThe elements in following table configure how your application scales. To learn\nmore about how App Engine apps scale, see\n[Scaling types](/appengine/docs/legacy/standard/php/how-instances-are-managed#scaling_types)."]]