如何在根文件夹和子文件夹中添加React App?

时间:2019-02-20 23:41:41

标签: reactjs apache react-router

我在域的根文件夹(例如www.abc.com)中有一个react应用。我还有另一个后端管理员react app,希望用户使用www.abc.com/admin访问。

现在,每次我尝试执行/ admin时,React App的主路由都选择/ admin并将我重定向到404 Not Found页面。它抓住了这一点:  

有没有办法构造应用程序,使其从/ admin中提取第二个管理应用程序?

我必须使用.htaccess文件来做到这一点吗?

这是根应用程序(反应样板)的.htaccess文件:

# Enable rewriting
  RewriteEngine On

 # If its not HTTPS
 RewriteCond %{HTTPS} off

# Comment out the RewriteCond above, and uncomment the RewriteCond below if you're using a load balancer (e.g. CloudFlare) for SSL
# RewriteCond %{HTTP:X-Forwarded-Proto} !https

# Redirect to the same URL with https://, ignoring all further rules if  
this one is in effect
RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R,L]

# If we get to here, it means we are on https://

# If the file with the specified name in the browser doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f

# and the directory with the specified name in the browser doesn't exist
RewriteCond %{REQUEST_FILENAME} !-d

 # and we are not opening the root already (otherwise we get a redirect loop)
 RewriteCond %{REQUEST_FILENAME} !\/$

 #REDIRECT FOR ADMIN - JUST A TEST TO SEE IF THIS WORKS

 Redirect 301 /admin http://www.google.com

 # Rewrite all requests to the root
 # RewriteRule ^(.*) /

0 个答案:

没有答案