首页 > 解决方案 > 使用 expo build:web 反应应用程序构建文件夹在主域的子目录中覆盖网址中的子 URL

问题描述

我把“主页”:“https://example.in/reactapplication/”放在 package.json 文件中。我使用 expo build:web 构建了应用程序,并将 web-build 文件夹的内容放在主域的子目录中。

一切运行良好意味着登录页面在我输入 https://example.in/reactapplication时显示,但它通过 URL https://example.in/reactapplication/重定向到https://example.in/Login但我期望它显示https://example.in/reactapplication/Login

同样在刷新页面时,它显示页面未找到。任何人都可以指出我的原因吗?

这是我的 App.json 文件

       const prefix = Linking.makeUrl('/');
         const linking = {
               prefixes: [prefix],
           }; 
       export default function App(){
        return(
              <NavigationContainer   linking={linking} fallback={<Text>Loading...</Text>}>
                <Stack.Navigator
     
                         initialRouteName='Login'
                 >
       
                   <Stack.Screen 
                                  name="Login"
                                   component={Platform.OS==='web'?LoginWeb:LoginAndroid} 
                                   options={{ title:null,headerShown:false}}
        
        
                   />
                    <Stack.Screen 
                       name="ForgotPassword" 
                       component={Platform.OS==='web'?ForgotPasswordWeb:ForgotPasswordAndroid} 
                         options={{ title:null,headerShown:false}}
                    />
         
       
               </Stack.Navigator>

              </NavigationContainer> 
         )
       }

.htaccess 代码是

<IfModule mod_rewrite.c>
      RewriteEngine on
       RewriteBase /reactapplication/ 
</IfModule

标签: apache.htaccessexporeact-navigation-stack

解决方案


推荐阅读