site 5x faster via mod_rewrite, but CSS images are broken

前端 未结 2 1481
陌清茗
陌清茗 2021-02-04 20:52

I am using .htaccess to accelerate a site with the following redirects:

request for http://example.com/images/name.jpg  routed to  http://i.example.com/name.jpg
r         


        
2条回答
  •  隐瞒了意图╮
    2021-02-04 21:23

    I was able to resolve this by not trying to incorporate directories into the subdomains:

    request for domain.com/images/  routed to  i.domain.com/images/
    request for domain.com/css/     routed to  c.domain.com/css/
    

    It works perfectly and is still extremely fast.

    There seems to be a bug in modern browsers where a css request that is redirected will apply only the new domain, leaving the original directories as part of the request:

    If a css image at url(domain.com/images/name.jpg) is redirected to i.domain.com/name.jpg, the browser will mistakenly request i.domain.com/images/name.jpg.

提交回复
热议问题