How to Set up Virtual Static Subdomain

Posted by Chip D on Stack Overflow See other posts from Stack Overflow or by Chip D
Published on 2010-06-09T23:16:25Z Indexed on 2010/06/09 23:22 UTC
Read the original article Hit count: 195

Filed under:
|
|

Given current rewrite rules at http://www.example.com/:

    Options +FollowSymlinks +Includes
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
    RewriteCond %{HTTP_HOST}   !^$
    RewriteRule ^/?(.*)        http://www.example.com/$1 [L,R,NE]

    # Remove all "index.html"s. 
    RewriteCond %{THE_REQUEST} \ /(.+/)?index\.html(\?.*)?\  [NC] 
    RewriteRule ^(.+/)?index\.html$ /%1 [R=301,L]

    # Remove all "index.php"s. 
    RewriteCond %{THE_REQUEST} \ /(.+/)?index\.php(\?.*)?\  [NC] 
    RewriteRule ^(.+/)?index\.php$ /%1 [R=301,L]

I'm attempting to serve some site assets (.png|.ico|.jpg|.gif|.css|.js) from a static subdomain like http://static.example.com which my Apache 1.3 shared host (GoDaddy) has mapped to a subdirectory for file management (http://www.example.com/static/). Currently these assets live in same-site subdirectories such as images/, js/, css/, etc.

(1) Something...maybe the "+www" rewrite rule?...is not letting me access the subdomain. Is this likely caused by my rewrite rules above, or do I need to set up DNS changes with the host to enable access to the subdirectory, in addition to changing the rewrite rules?

(2) Do I have to move those assets to that subdirectory and change all references sitewide? Would that perform the fastest?

(3) Or can .htaccess make this much easier?

(4) Should my first rewrite rule above include L,R=301,NE instead of [L,R,NE]?

© Stack Overflow or respective owner

Related posts about static

Related posts about subdomain