nginx 重写Response Header Content-Language

为了SEO优化,需要确保返回正确的Content-Language响应头。在nginx中进行了配置,如在http://localhost/french和http://localhost/japanese等环境下测试通过。注意,nginx的add_header指令不能修改除以外的头部,推荐使用headers_more模块,但Windows环境下编译扩展不便,故采用当前解决方案。
摘要由CSDN通过智能技术生成

最近做SEO优化,要求返回正确的Content-Language;

response.setHeader("Content-Language", "ja");//这个设置没用,这个值跟操作系统有关

 于是在nginx重写这个值,简略配置如下;

 

环境 :http://localhost/french;http://localhost/japanese........等;

 

 

        
location /{
	proxy_hide_header 'Content-Language'; #隐藏掉之前的值
	if ($request_uri ~* "/china"){ #根据不同的国家添加不同的值
		add_header Content-Language cn;
	}
	if ($request_uri ~* "/japanese"){
		add_header Content-Language ja;
	}
	if ($request_uri ~* "/french"){
	        add_header Content-Language fr;
	}
	proxy_pass http://home_server;
			
}
		
rewrite /china /test/index.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值