如何将manifest.json的start_url设置为网站的根?

问题描述:

我有一个manifest.json,它有一个start_url属性,我想指向我的单页应用程序的第一个文件。如何将manifest.json的start_url设置为网站的根?

这是index.html,它是网站的根。我希望这是start_url,但该文件永远不会被要求作为URL。

我该如何指向start_url位于网站的相对根目录?

+2

您可以使用'start_url'的相对路径,所以''start_url“:”./index.html“'应该可以工作 - 或者这不是您的意思?另见:https://developer.mozilla.org/en-US/docs/Web/Manifest#start_url。 –

+0

@TomDavies然后用户转到“https:// example.com/app”,但起始URL变成了“https:// example.com/app/index.html”或“https://example.com/index” .html'。 – Keith

+0

目前尚不清楚汤姆的回应为什么不能达到你所要求的。使用。“./index.html”或'“./”'(如果你不想包含'index.html',出于某种原因)应该可以工作。 –

此行添加到您的manifest.json

“START_URL”: “WhereEverYouNeedToRedirect”,

确保你保持你的manifest.json的结构

下面的文章可能会有所帮助:

https://developers.google.com/web/fundamentals/web-app-manifest/

https://developer.mozilla.org/en-US/docs/Web/Manifest

+0

嗨,欢迎来到所以。这个问题应该很清楚,但这不是关于如何设置'start_url',而是关于如何将其设置为默认路由。 – Keith