Reputation: 3
I know this question has been asked many times in stack overflow, but I am not able to get the correct results.
I tried this link : htaccess redirect for Angular routes
so basically ,i am using https://github.com/angular-ui/ui-router for navigation in my app,
we have a url like this :
www.xyz.com/products <= this url working fine, ( on hard refresh it is working fine )
www.xyz.com/displayOrders/12 <= this url is not working when we do hard refresh from browser. WHY?
also my nested views are not working :
what i wrote in .htaccess file is :
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule (.*) index.html [L]
</IfModule>
my base tag is this :
<base href="/"> and i also made html5mode as true in app.js
Upvotes: 0
Views: 945
Reputation: 11
You should write .htaccess like this
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule (.*) /index.html [L]
</IfModule>
If your project in subdirectory example: www.xyz.com/shop/
You should write last rewriterule like this
RewriteRule (.*) /shop/index.html [L]
and base tag like this
<base href="/shop/">
Upvotes: 1