Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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
Regex 使用正则表达式进行Firebase重定向_Regex_Firebase_Redirect_Firebase Hosting - Fatal编程技术网

Regex 使用正则表达式进行Firebase重定向

Regex 使用正则表达式进行Firebase重定向,regex,firebase,redirect,firebase-hosting,Regex,Firebase,Redirect,Firebase Hosting,我的目标是将任何不以特定符号(“#”)开头的URL重定向到其他网站。 我正在使用Firebase托管,并且已经尝试了重定向中的Regex函数来实现这一点。我在重定向上遵循了这个firebase,但因为我不熟悉正则表达式,所以我认为我的错误可能是我的正则表达式代码 我的目标是: mydomain.com/anyNotStartingWith#=>otherdomain.com/anyNotStartingWith# mydomain.com/#any=>mydomain.com/#any 我的

我的目标是将任何不以特定符号(“#”)开头的URL重定向到其他网站。 我正在使用Firebase托管,并且已经尝试了重定向中的Regex函数来实现这一点。我在重定向上遵循了这个firebase,但因为我不熟悉正则表达式,所以我认为我的错误可能是我的正则表达式代码

我的目标是:

  • mydomain.com/anyNotStartingWith#=>otherdomain.com/anyNotStartingWith#
  • mydomain.com/#any=>mydomain.com/#any
我的代码:

{
  "hosting": {
    ...
    "redirects": [
      {
        "regex": "/^[^#]:params*",
        "destination": "otherdomain.com/:params",
        "type": 301
      }
    ],
    ...
  }
}
你可以用

"regex": "/(?P<params>[^/#].*)"
/(?P<params>[^/#].*(?:[^.].{2}$|.[^j].$|.{2}[^s]$))$


有关如何否定模式的详细信息,请访问。

尝试
“regex”:“/(-p[^/#][^/]*)”
,或
“regex”:“/(-p[^/#].*”
@WiktorStribiżew感谢您的帮助,两者都有效!是否有一种方法可以向这个表达式中添加一些内容来检查URL是否以.js结尾,并且不允许这样做。因此mydomain.com/any.js也不会被重定向。