Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.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
Javascript React应用程序显示“;404找不到页面“;在新选项卡中打开时出错_Javascript_Html_Reactjs - Fatal编程技术网

Javascript React应用程序显示“;404找不到页面“;在新选项卡中打开时出错

Javascript React应用程序显示“;404找不到页面“;在新选项卡中打开时出错,javascript,html,reactjs,Javascript,Html,Reactjs,已将react应用程序从本地环境迁移到live server,迁移后,如果在新选项卡中打开,菜单链接将抛出404错误 网站链接: 菜单位置:右上角标题菜单 <ul class="_1xWsKFr _2rbE6TC _2v5bHvx pRZSkbx"> <li class="_1GxILA2"> <a aria-current="page" class="_2Vj-OOq _2_HaYMw _1w_OEYg active" href="/"&g

已将react应用程序从本地环境迁移到live server,迁移后,如果在新选项卡中打开,菜单链接将抛出404错误

网站链接: 菜单位置:右上角标题菜单

<ul class="_1xWsKFr _2rbE6TC _2v5bHvx pRZSkbx">
    <li class="_1GxILA2">
        <a aria-current="page" class="_2Vj-OOq _2_HaYMw _1w_OEYg active" href="/">
            Home
        </a>
    </li>
    <li class="_1GxILA2">
        <a class="_2Vj-OOq _2_HaYMw _1w_OEYg" href="/about">
            About Us
        </a>
    </li>
    <li class="_1GxILA2">
        <a class="_2Vj-OOq _2_HaYMw _1w_OEYg" href="/contact-us">
            Join PLEJ Fitness
        </a>
    </li>
    <li class="_1GxILA2">
        <a class="_2Vj-OOq _2_HaYMw _1w_OEYg" href="/location">
            Locations
        </a>
    </li>
    <li class="_1GxILA2">
        <a class="_2Vj-OOq _2_HaYMw _1w_OEYg" href="/careers">
            Careers
        </a>
    </li>
    <li class="_1GxILA2">
        <a class="_2Vj-OOq _2_HaYMw _1w_OEYg" href="/owngym">
            Own A Gym
        </a>
    </li>
    <li class="_1GxILA2">
        <a class="_2Vj-OOq _2_HaYMw _1w_OEYg" href="/gallery">
            Gallery
        </a>
    </li>
    <li class="_1GxILA2">
        <a class="_2Vj-OOq _2_HaYMw _1w_OEYg" href="/contact-us">
            Contact Us
        </a>
    </li>
</ul>

根文件夹中包含以下代码的.htaccess文件已修复此问题

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule . /index.html [L]

</IfModule>

重新启动发动机
重写基/
重写规则^index\.html$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-L
重写规则/index.html[L]

您的代码在哪里?看起来React路由器配置不正确。您的站点似乎是一个单页应用程序,因此在新选项卡中路由似乎无法正常工作。它在本地工作吗?是的,它在本地版本上工作正常。您看到的是服务器的404页,而不是React应用程序。您的服务器未配置为在这些路径上为您的应用提供服务,仅在
/