Reactjs .htaccess-在两个应用程序之间重定向
我在同一子域中有两个react应用程序-在不同的目录中Reactjs .htaccess-在两个应用程序之间重定向,reactjs,.htaccess,mod-rewrite,url-rewriting,friendly-url,Reactjs,.htaccess,Mod Rewrite,Url Rewriting,Friendly Url,我在同一子域中有两个react应用程序-在不同的目录中 app.domain.com app.domain.com/login 为了使react路由器工作,我有现有的.htaccess规则将所有流量重定向到应用程序(index.html) 我想允许在目录/login中加载react应用程序,并将所有/login/*请求重定向到/login/index.html 如何使用.htaccess应用这些规则 非常感谢/K您现有的。htaccess很好。只需在/login/目录下创建另一个.htacces
.htaccess
规则将所有流量重定向到应用程序(index.html)
我想允许在目录/login
中加载react应用程序,并将所有/login/*
请求重定向到/login/index.html
如何使用.htaccess
应用这些规则
非常感谢/K您现有的。htaccess很好。只需在
/login/
目录下创建另一个.htaccess
,如下所示:
RewriteEngine On
#Redirect all to index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
这将把每一个非文件和非目录的
/login/*
请求路由到/login/index.html
,您可以尝试以下内容吗。请确保在测试URL之前清除浏览器缓存
RewriteRule ^login/?$ login/index.html [NC,L]
或者uri开始登录时在uri中有其他内容
RewriteRule ^login(?!=index\.html) login/index.html [NC,L]
对这很有效-非常感谢!(^__^)/
RewriteRule ^login(?!=index\.html) login/index.html [NC,L]