Subdomain images!

Hello! friends,

Help me please! I’ve created a subdomain “img” for images but it does not work.

MY COMMANDS:

1) - ee site create img.domain.com = (Ok!)

2) - I created DNS Record A point to IP domain = (Ok!)

3) - nano /etc/nginx/sites-available/domain.com = (Ok!)

4) - I added line…: sub_filter “domain.com/wp-content/uploads/” “img.domain.com/wp-content/uploads/”;

Is correct? something is missing?

The images are still in…: domain.com/wp-content/uploads/photo.jpg I wish…: img.domain.com/wp-content/uploads/photo.jpg

Thank you all for helping me. Regards,

Carlosara

Hello @Carlosara,

you can find an example of nginx configuration with sub_filter module on http://nginx.org/en/docs/http/ngx_http_sub_module.html#sub_filter

But if you are using a sub-domain to improve your website loading speed with domain sharding, I can only recommend you to enable https on your website to use HTTP/2. It provide better loading speed than loading assets from a subdomain. It’s an outdated directive you can often see on websites like tools.pingdom.com

Hello! Virtubox.

Thank you for helping me with your information and link.

What commands should I use for images to open in subdomain (img)?

img.domain.com/wp-content/uploads/photo.jpg

I have never used this nginx module previsouly, but for me your configuration should look like :

    sub_filter 'https://yourwebsite.tld/wp-content/uploads/' 'https://img.yourwebsite.tld/wp-content/uploads/';
    sub_filter_once off;
  }