我有一個angularjs應用程序,它也有一個博客。該網址顯示下nginx匹配特定路徑上來自不同文件夾的特定文件
http://example.com/blog/example-blog-post-title
下
http://example.com/blog/
所有博客文章和特定的博客帖子現在我預編譯的博客文章的搜索引擎優化目的的HTML,我想從我的主要的應用程序完全獨立地爲他們服務像這樣:
...
root "/home/ubuntu/client/public";
location/{ ## Handle default requests ##
try_files $uri $uri/ /index.html;
}
location /blog { ## serve precompiled blog HTML
alias /home/ubuntu/bloghtml;
try_files $uri.html $uri/ index.html;
}
...
而這個工作,通過將http://example.com/blog/example-blog-post-title nginx的成功提供文件/home/ubuntu/bloghtml/example-blog-post-title.html
但問題是,在這種情況下,nginx並沒有正確地將博客帖子列表http://example.com/blog/路由到我的主角應用程序,我得到該URL的錯誤403。
我試過的conf文件中更改location /blog
到location /blog/
,這使得http://example.com/blog/工作,howewever我得到http://example.com/blog/example-blog-post-title
404錯誤,我怎樣才能使這項工作,對於兩種情況?
[如果我理解正確] 如果您是URL包含/博客(例如:http://example.com/blog/some-post.html)將始終從/ home/ubuntu/bloghtml根。如果您想將請求轉發給您的角度應用程序,您可能需要爲其拍攝不同的位置指令。 – RaviTezu