mod rewrite - Cloudfront CDN to Apache origin -
mod rewrite - Cloudfront CDN to Apache origin -
i running issue website www.example.com mapped aws cloudfront. however, i'd have cloudfront cdn pass host "www.example.com" origin server retrieve content. doesn't feature available on cloudfront pretty sure on other cdn providers llnw etc.
now around this, can utilize record of "example.com" origin on server side can cause duplicate content issue , i'm redirecting non-www www in apache config:
rewritecond %{http_host} ^example\.com$ [nc] rewriterule ^/(.*)?$ http://www.example.com/$1 [r=301,nc,ne,l] is there way have rule above except *.cloudfront.net domains? way can ensure traffic coming cloudfront.net able utilize "example.com" origin without getting redirected "www.example.com", causing loop issue.
here rule had set in place:
rewritecond %{http_host} ^example\.com$ [nc] rewritecond %{http_host} !^.cloudfront\.net$ [nc] rewriterule ^/(.*)?$ http://www.example.com/$1 [r=301,nc,ne,l] however, not work had hoped.
any suggestions appreciated.
thanks!
your sec status has little bug.
!^.cloudfront\.net anchored, , hence specifies host must not match exactly 1 character (specified .) followed cloudfront.net. never match, status true, , cloudfront not excluded.
replace status unanchored one, 2 conditions become:
rewritecond %{http_host} ^example\.com$ [nc] rewritecond %{http_host} !cloudfront\.net$ [nc] apache mod-rewrite amazon-cloudfront
Comments
Post a Comment