【发布时间】:2021-12-29 08:21:06
【问题描述】:
我在使用 firebase 托管的网页上重写 url 时遇到问题。 这就是我的 firebase.json 的样子。
{
"hosting": {
"cleanUrls": true,
"trailingSlash": true,
"headers": [ {
"source": "*.php",
"headers": [ {
"key": "Content-Type",
"value": "text/html"
} ]
} ],
"appAssociation": "AUTO",
"public": "public",
"rewrites": [
{
"source": "**/!(*.css|*.js|*.map|*.jpg|*.gif|*.png|*.php),/post/**",
"dynamicLinks": true
}
]
}
}
到目前为止一切顺利。我遇到的问题不起作用。 例如,当我的网页托管在 https://google.com
上时我的内部联系页面目前在https://google.com/contact.php
这行得通,但那行不通https://google.com/contact 但这就是我想要的。另外,也许您可以检查我是否正确并给出了 2 条重写规则,第一个规则是这样的
"**/!(*.css|*.js|*.map|*.jpg|*.gif|*.png|*.php)",
第二个是这个
/post/**
我可以一起写还是应该自己重写标签
/post/**
【问题讨论】:
-
Firebase 托管不提供/解释 PHP 代码。您确定文件扩展名是您的主要问题吗?
-
是的,它使用 Headers Firebase firebase 将 php 代码读取为 html 我认为 stackoverflow.com/questions/61963981/…。所以它有效,我可以看到它有效。但我不知道为什么仍然没有 .php 网络服务器找不到页面
标签: php html firebase url-rewriting firebase-hosting