Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将.htaccess文件转换为Firebase主机配置?_.htaccess_Url Rewriting_Firebase Hosting - Fatal编程技术网

如何将.htaccess文件转换为Firebase主机配置?

如何将.htaccess文件转换为Firebase主机配置?,.htaccess,url-rewriting,firebase-hosting,.htaccess,Url Rewriting,Firebase Hosting,我已经在Angular 2中建立了一个水疗中心,我正在Firebase主机上托管它。 我专门为爬网机器人构建了som额外的静态html页面,因为它们不读取更新的动态html,只读取初始index.html,现在我需要将来自机器人的HTTP请求的URL重写到这些静态页面 我知道如何在.htaccess文件中执行此操作,但我不知道如何在firebase.json文件中转换重写条件 这是我的.htaccess: 我已经在上阅读了Firebase的文档,但不知道如何针对特定的用户代理 有什么想法吗?Fi

我已经在Angular 2中建立了一个水疗中心,我正在Firebase主机上托管它。 我专门为爬网机器人构建了som额外的静态html页面,因为它们不读取更新的动态html,只读取初始index.html,现在我需要将来自机器人的HTTP请求的URL重写到这些静态页面

我知道如何在.htaccess文件中执行此操作,但我不知道如何在firebase.json文件中转换重写条件

这是我的.htaccess:

我已经在上阅读了Firebase的文档,但不知道如何针对特定的用户代理


有什么想法吗?

Firebase主机不支持基于用户代理标头配置重写。它可以支持基于路径和的重写


据我所知,基于其他头文件重写的唯一选择是使用代码进行重写。但这与在firebase.json文件中配置重写有很大不同,因此我建议在选择此路径之前先阅读一遍。firebase主机不支持基于用户代理头配置重写。它可以支持基于路径和的重写

据我所知,基于其他头文件重写的唯一选择是使用代码进行重写。但这与在firebase.json文件中配置重写有很大不同,因此我建议在选择此路径之前先阅读一遍

RewriteEngine On
 
# Remove trailing /
RewriteRule ^(.*)/$ /$1 [L,R=301]
 
# Rewrite spiders to static html
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|msnbot|yahoo|Baidu|aolbuild|facebookexternalhit|iaskspider|DuckDuckBot|Applebot|Almaden|iarchive|archive.org_bot) [NC]
RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ /static/$1.html [L]
 
# Rewrite spiders to static index.html
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|msnbot|yahoo|Baidu|aolbuild|facebookexternalhit|iaskspider|DuckDuckBot|Applebot|Almaden|iarchive|archive.org_bot) [NC]
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule ^ /static/index.html [L]
 
# If an existing asset or directory is requested, serve it
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
 
# If the requested resource doesn't exist, use the Angular app entry point
RewriteRule ^ /index.html