Reputation: 4671
I'm trying to use AngularJs
with html5mode
enabled, and to be able to use it i need to enable a rewrite
i need an .htaccess
to point to the folder.
When going to the root index
, there is no problem, everything works fine. But when i try to redirect to a subfolder where there is another section, i keep getting errors. For example, i have an admin section to publish news, etc.. So to access this portion of the app i need to go to a subfolder called /adm
like this www.site.com/adm
and this is where the errors starts.
This is my .htaccess
file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
And this is the errors I'm getting:
Uncaught SyntaxError: Unexpected token <
When looking further, i see this is point to the index on the root. I know it has something to do with the .htaccess
file, but i don't how to create a rule to identify if it's a root folder or sub folder and create the proper rewrite rule.
Upvotes: 0
Views: 807
Reputation: 7856
Try this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(adm/)?index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(adm/)?. /$1index.html [L]
</IfModule>
What this does is rewrite everything inside /adm/
to /adm/index.html
and everything else to /index.html
Upvotes: 1