1

How can an AngularJS site's url be automatically rewritten from example.com/app to example.com/app/#/?

Currently, it changes from example.com/app to example.com/app#/.

1 Answer 1

1

You can use this rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?[^/])$ /$1/#/ [L,NE,R=302]
Sign up to request clarification or add additional context in comments.

6 Comments

It doesn't seem to work. AngularJS does add a # to the URLS to allow to browser to handle further links. Maybe that has something to do with it.
If you enter example.com/app what does it become?
It becomes example.com/app#/
Open example.com/app in Chrome dev tool to see what does it get redirected to? Make sure there is one rule as shown above.
It does work when I have only one redirect rule. However, then I get a 404 error. Thanks for your help. I'm going to play around with this for a while.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.