October 2017

How to assign different separate domain for a Drupal page using Nginx

A client asked me to work on one particular page of his existing Drupal site to have its own different separate domain. This is one good solution if you have special web page that you want to quickly improve ranking on search engines.

Lets say, the http://www.webfoobar.com/node/88 is the page that we want it to have its own domain "test7.webfoobar.com". The following steps will accomplish this task:

Nginx solution to web static files are blocked by CORS policy: No 'Access-Control-Allow-Origin' header

If a website is trying to access web static files from different URL domain, broken web assets and the following error will occur:

Access to Font at 'https://www.webfoobar.com/sites/webfoobar.com/themes/custom/mybootstrap/fonts/sniper.woff?1887860575' from origin 'https://test7.webfoobar.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://test7.webfoobar.com' is therefore not allowed access.