Motivation
I purchased a .tech
domain recently, and made it a alias domain to hollen9.com
.
However, some src request are blocked due to CORS policy.
Typical symptoms are blank images, failure to load external fonts, scripts, etc. You can verify it by checking your dev console on the browser by pressing Shift
+Ctrl / Command
+i
.
Solution
Locate your .htacess
file of your website, for analog it is a config file just like web.config on IIS.
Open it with a text editor, insert the following:
<IfModule mod_headers.c>
# Allow loading of alias domain resources
# You should modify the domains to suit your need.
SetEnvIf Origin "http(s)?://(www\.)?(holllen.tech|hollen9.com)$" AccessControlAllowOrigin=$0
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header merge Vary Origin
</IfModule>
Force reload your previous page by pressing Ctrl
+F5
or Command
+Shift
+R
, and viola! Now all images are visible!
Facebook 留言