Module rewrite in .htaccess for sub folders

3

I have an application in AngularJs with html5 enabled, which causes me to use apache rewrite module for the correct conversion of the URL.

I have no problem to use this when accessing the application with the index from the root, that is, if I access www.meusite.com.br and navigate the menus, refresh the page, etc .. everything works correctly. >

The problem starts when I need to access a new area of app that starts in a sub-folder, for example, my administrative area. It is all stored in a sub folder called adm being accessed like this: www.meusite.com.br/adm

In this sub folder, I have a new index, new sub folders, etc. A new area of app is only focused on administration and it is in this part that I am having problems using module rewrite with html5 , because when updating the page it no longer finds the path, in case it tries to start from the index of the root.

This is my file .htaccess located at the root of app .

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
</IfModule>

In theory I know I would need a rule that points to the sub folder as well, but I do not know how to create this rule and I could not find anything yet.

    
asked by anonymous 14.04.2016 / 14:59

1 answer

3

You will have to create another .htacess , save it in the adm folder and change the second and last line:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /adm
    RewriteRule ^index.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /adm/index.html [L]
</IfModule>

In this case, the "root" will be pointed to /adm (second line) and when entering the root, it will search the index.html (last line).

    
14.04.2016 / 15:10