开发者

Set up a Sub Domain: ex -- "www.example.com" to store images at "images.example.com"

I have searched on this site and through general google.com sites for an easy answer to this question, but apparently I don't know the r开发者_运维问答ight keywords to evoke a useful answer. I've noticed that Google does this with various extensions to its search engine, like "code.google.com, mail.google.com, etc.", but I can't find any documentation how they did it...

I am developing a site using LAMP and I've read that its a good idea to set up a separate domain to host site assets, or even set up another domain to support an extension to the main site.

So for example if I have a (theoretical) domain of "www.example.com" is it possible (and how do I do it?) to set up a domain with the URL of "images.example.com"? I suspect it involves using DNS or writing a .htaccess file, or something, but I just don't know.

I'm not looking for a full answer (although that would be nice if you have a concise one), if you could confirm that this is possible and point me towards documentation, manuals, instructional websites, etc. that would be really cool.

I appreciate you taking a look at this post and thank you in advance for any helpful answers provided.


This is actually pretty easy. If everything is on the server, on the DNS side you can add a `CNAME' record that points to your tld.

images.example.com. 300 IN CNAME example.com.

This gives the freedom to change the IP of example.com (ie changing servers), and the subdomain will follow.

On the apache side, you simply set up an additional vhost that will serve files from the directory that contains all your images.

<VirtualHost 4.2.2.2:80>
    DocumentRoot /path/to/your/webroot/images
    ServerName imaages.example.com
    <Directory /path/to/your/webroot/images>
        Options -Indexes
        AllowOverride all
    </Directory>
</VirtualHost>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜