0

On apache server I set up a domain.com and a subdomain media.domain.com. I need the media subdomain to serve exact same files. I added inside sites-available/domain.com following

<VirtualHost *:80>
    VirtualDocumentRoot /data/web/domain.com
ServerName domain.com
    ServerAlias media.domain.com
</VirtualHost>

My question is how to prevent the subdomain from beeing crawled and considered as duplicate? Should I allow access only to files folder? Or what is the best practice in my case? My aim is to only serve files like images from subdomain. Thank you.

Stefan Lasiewski
  • 23,667
  • 41
  • 132
  • 186
user1031742
  • 103
  • 5
  • If you intend to serve only static content from the subdomain, why do you want the same files available on both domains? – Michael Hampton Jan 30 '14 at 17:31
  • I try to use CDN module (for drupal) so this module can rewrite all image paths to media.domain.com/. The page loag times should be faster. – user1031742 Jan 30 '14 at 17:34

2 Answers2

0

Best practice might well be to establish both services (domain and subdomain), and use mod_rewrite on your "unpreferred" choice to redirect all queries to your preferred choice.

Kevin_Kinsey
  • 111
  • 4
0

You can use redirects (as already suggested):

NameVirtualHost *:80 ServerName domain.com DocumentRoot /data/web/domain.com ServerName alias.domain.com Redirect permanent / http://domain.com/

Alternatively, you do nothing on the server but signal search engines (e.g. via Google webmaster tools) that the two sites are an alias of each other.