问题描述
Polymer Starter Kit(PSK)包含有关在Firebase上托管时使用Pretty URL的说明这里
the Polymer Starter Kit (PSK) contains instructions on using Pretty URLs when hosting on Firebase HERE
我正在尝试使用Nginx Server做类似的事情,但是无法弄清楚页面重新加载的位置块.例如,使用PSK随附的示例数据,您将如何配置"/users/sam".
I am attempting to do similar using Nginx Server, but cannot figure out the Location Block for page reloads. Using the sample data that comes with PSK, how would you configure "/users/sam", for example.
推荐答案
nginx配置
server {
listen 80;
server_name example.com;
root /home/myuser/psk/dist;
index index.html;
location /
{
try_files $uri /index.html;
}
}
确保将 基本URL 添加到您的 index.html .如果是聚合物入门工具包& nginx基本元素将帮助直接访问带有查询参数的URL,例如: http://example.com/users/Chuck 您可以在PSK 1.2.x的用户"下找到
Make sure to add a base url to your index.html. In case of Polymer starter kit & nginx the base element will help direct access to URLs with query parameters such as : http://example.com/users/Chuck that you can find under "Users" in PSK 1.2.x
<html>
<head>
<base href="/">
...
否则,nginx将进入没有基本URL的循环.
Otherwise nginx will go into a loop without a base URL.
nginx error.log
nginx error.log
浏览器进入无限循环加载索引页面而不是静态文件.
Browser goes into an infinite cycle loading the index page instead of static files.
这篇关于Polymer入门工具包-Nginx服务器上的漂亮URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!