Sub folder configuration in htaccess

0

Well I have a hosting with the following structure:

index.html
.htaccess
app
site

Well, inside the app folder I have an application compiled in Angular 7.0 and inside the site folder I also have a site made in Angular 7.0.

Well for Angular routing to work I have to make the following configuration in htaccess :

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /index.html?path=$1 [NC,L,QSA]

But I do not want to have to create a htaccess for each folder, I wanted to do all the configuration in the htaccess that is in the root.

I tried to do this:

# Configurações do url
<IfModule mod_rewrite.c>
RewriteEngine On

# Angular APP
RewriteBase /app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /app/index.html?path=$1 [NC,L,QSA]

# Angular Site
RewriteBase /site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /site/index.html?path=$1 [NC,L,QSA]
</IfModule>

But htaccess is only respecting the first setting (# Angular APP).

Do you have any way to resolve this?

    
asked by anonymous 21.11.2018 / 19:19

1 answer

1

Is he not ignoring the folder? Please try deleting the second option like this:

# Configurações do url
<IfModule mod_rewrite.c>
RewriteEngine On

# Angular APP
RewriteBase /app/
RewriteCond %{REQUEST_URI} !^/site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /app/index.html?path=$1 [NC,L,QSA]

# Angular Site
RewriteBase /site/
RewriteCond %{REQUEST_URI} !^/app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /site/index.html?path=$1 [NC,L,QSA]
</IfModule>
    
21.11.2018 / 19:28