Nginx-如何在使用try\u文件时为index.html添加标题
我有以下配置(对于Angular应用程序): 现在,我只想为Nginx-如何在使用try\u文件时为index.html添加标题,nginx,http-headers,cache-control,Nginx,Http Headers,Cache Control,我有以下配置(对于Angular应用程序): 现在,我只想为index.html添加该标题,而不想为任何其他文件添加该标题。怎么做 使用“=”修饰符可以定义URI的精确匹配 和位置。如果找到完全匹配,搜索将终止 因此,您可以使用此配置: location =/index.html { add_header "Cache-Control" "no-cache" ; } location / { rewrite ^(.*) /index.html break; } 您可
index.html
添加该标题,而不想为任何其他文件添加该标题。怎么做
使用“=”修饰符可以定义URI的精确匹配
和位置。如果找到完全匹配,搜索将终止
因此,您可以使用此配置:
location =/index.html {
add_header "Cache-Control" "no-cache" ;
}
location / {
rewrite ^(.*) /index.html break;
}
您可以在中找到更多信息
尝试添加location=/index.html{//在这里添加带有“=”前缀的指令}指令,这些指令与查询完全匹配。如果找到,搜索将停止。
location =/index.html {
add_header "Cache-Control" "no-cache" ;
}
location / {
rewrite ^(.*) /index.html break;
}