根目录和子目录的角.htaccess [英] Angular .htaccess for root and subdirectory
问题描述
我正在单个服务器上使用多个角度项目,这是我项目的文件夹结构
I am using multiple angular projects on single server, This is my folder structure of my projects
Root: Project-1
Root/test : Project2
Root/test/new : project3
这是我正在使用的htaccess代码.但是子目录项目有时无法正常工作
Here is the htaccess code, that I am using. but subdirectory projects not working some times
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
问题是,当我尝试使用此URL www.domain.com/test
访问第二个项目时,将其重定向到 root
文件夹,即 project1
.我认为当iIaccess project2时,它正在检查project1路由
The issue is, when I am trying to access the second project using this url, www.domain.com/test
, its redirecting to root
folder, that is project1
. I think it's checking project1 routing, when iIaccess project2
如何解决此问题.
推荐答案
我有一个类似的项目结构,下面的 .htaccess 为我工作.
I have a similar project structure and the below .htaccess works for me.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
</IfModule>
看看是否有效.
这篇关于根目录和子目录的角.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!