简体   繁体   English

React 应用程序在新选项卡中打开时显示“404 page not found”错误

[英]React application showing “404 page not found ” error when open in new tab

Have migrated a react application from my local environment to live server, post migration the menu links are throwing a 404 error if opened in new tab.已将 React 应用程序从我的本地环境迁移到实时服务器,迁移后如果在新选项卡中打开菜单链接,则会引发 404 错误。

website link: http://www.plejfitness.com/ Menu location: Top right header menu网站链接: http://www.plejfitness.com/菜单位置:右上角 header 菜单

<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>

An .htaccess file with following code in the root folder has fixed the issue根文件夹中包含以下代码的 .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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM