I want to create a separate domain for images

I want to create a domain called img.mydomain.com. This is a virtual domain that is exactly the same as my actual domain, with one exception: it will only serve files that end in .jpg.jpeg.gif.png, etc. Thus, I can refer to img.mydomain.com/some_image.jpg, this will speed up the page speed, making the browser think that these are two separate domains (the google page speed analyzer always forces me to do this).

I am running apache on a linux server. Should I do this in httpd.conf? If so, what is my first step?

+5
source share
1 answer

create 2 folders for each domain (for example):

  • /var/www/domain.com
  • /var/www/img.domain.com/

httpd.conf

<VirtualHost *:80>
  DocumentRoot "/var/www/domain.com"
  ServerName domain.com
  ServerAlias domain.com www.domain.com
  <Directory "/var/www/domain.com">
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "/var/www/img.domain.com/"
  ServerName img.domain.com
  ServerAlias img.domain.com
  <Directory "/var/www/img.domain.com/">
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>
+6

All Articles