我有nginxconfiguration为服务单页React.js应用程序作为静态内容。 react-router在浏览器中处理路由。
为了使用户能够直接在地址栏中input所有的url(不仅仅是域example.com ,还包括像example.com/some/path等)我在做,
error_page 404 /index.html
除了在Internet Explorer中,这在任何地方都可以工作。 IE显示了404页面。
如果请求path无法与根目录中的文件匹配,如何configurationnginx以使其服务于index.html。
谢谢。
这是一个try_files的工作。
try_files $uri /index.html;
$uri会加载任何静态资源,如果它们存在且可访问的话; 对于任何不可访问的URL,/ /index.html将被提供(200)。
作为解决方法,您可以使用
server { listen 80; server_name www.example.net; root /vhosts/default/public_html; error_page 404 =200 /index.html; location / { index index.html; } }
IE浏览器显示你的caching版本有可能吗?
IE似乎默认行为。 至less在Windows 7上的IE11
PS事实certificate,您的index.html必须是512 +字节