I have a mean-stack
website with html5mode
enabled. In index.html
, I have <base href="/1/" />
. And I have the following nginx setting such that www.myweb.com/home
becomes automatically www.myweb.com/1/home
(www.myweb.com/js/abc.js
remains www.myweb.com/js/abc.js
):
location ~* ^/\b(?!1|stylesheets|js)\w+\b/? {
rewrite .* /1$request_uri redirect;
}
Now, I have to add a special library, which unfortunately disables html5mode
. So I am going to give up html5mode
for the whole websites.
So now, I expect a rewrite rule such that
www.myweb.com/home ==> www.myweb.com/1/#/home
www.myweb.com/js/controller.js ==> www.myweb.com/js/controller.js
www.myweb.com/1/abc/def ==> www.myweb.com/1/#/abc/def
www.myweb.com/1/#/abc/def ==> www.myweb.com/1/#/abc/def
Does anyone know how to modify the above rewriting to enable this? Because my website is already online. I want to make sure the rules before changing the production...
Edit 1: I guess if I write
location ~* ^/\b(?!1|stylesheets|js)\w+\b/? {
rewrite .* /1/#$request_uri redirect;
}
That will result in
www.myweb.com/home ==> www.myweb.com/1/#/home (correct)
www.myweb.com/js/controller.js ==> www.myweb.com/js/controller.js (correct)
www.myweb.com/1/abc/def ==> www.myweb.com/1/abc/def (wrong)
www.myweb.com/1/#/abc/def ==> www.myweb.com/1/#/abc/def (correct)