perusio / drupal-with-nginx

Running Drupal using nginx: an idiosyncratically crafted bleeding edge configuration.
855 stars 246 forks source link

content redirect from one site to another when using subdomain for sites/default/files in drupal #283

Open gs9999 opened 6 years ago

gs9999 commented 6 years ago

Hello Perusio,

I HAD come across another article/ post of yours a while back, where you had something that, unfortunately, I cut and paste, however, can't currently find again, that made it so that on a static serving nginx website,

that I am using to host sites/default/files content, on a subdomain, in drupal,

there was a DIRECTIVE that made it so nginx would try to load from the subdomain location {}, and for imagestyles purposes, would try to load from the www.example.com main drupal domain, so that the image would be generated, if it was not available on the subdomain i.e. (content.example.com) @ nginx serving time.

could you mind posting the info here in this forum, so that those of us that use this www.github.com/perusio/drupal-with-nginx easily reference when re-building servers?

Thanks.

GS

gs9999 commented 6 years ago

Hello everybody,

I was able to find the nginx config code/language that I was looking for. For anyone else looking for this subject matter. It goes like this

put this at the head of your config

map $uri&$args $no_slash_uri { ~^/(?<no_slash>.*)$ $no_slash; }

the in a server curly brace or directive, put the following location --

location ~* /sites/default/files/styles/* {

           access_log off;
           expires 30d;

    error_page 400 = https://www.example.com/index.php?q=$no_slash_uri;
    error_page 500 = https://www.example.com/index.php?q=$no_slash_uri;
    error_page 404 = https://www.example.com/index.php?q=$no_slash_uri;
}

thanks, perusio for all your help and assistance--glad I could contribute back.

GS