Rewrite for robots.txt and favicon.ico

Posted by BHare on Pro Webmasters See other posts from Pro Webmasters or by BHare
Published on 2011-02-17T23:50:15Z Indexed on 2011/02/20 23:32 UTC
Read the original article Hit count: 372

Filed under:
|

I have setup some rules in which subdomains (my users) will default to where I have located the robots.txt, favicon.ico, and crossdomain.xml

therefore if a user creates a site say

testing.mywebsite.com and they don't make their own favicon.ico at testing.mywebsite.com/favicon.ico, then it will use the favicon.ico I have in /misc/favicon.ico

This works perfect, but it doesn't work for the main website. If you attempt to go to mywebsite.com/favicon.ico it will check if "/" exists, in which it does. And then never redirects to /misc/favicon.ico

How can I get it so both instances redirect to /misc/favicon.ico ?

    # Set all crossdomain (openpalace file) favorite icons and robots.txt doesnt exist on their
    # side, then redirect to site's just to have something to go on.
RewriteCond     %{REQUEST_URI}          crossdomain.xml$
RewriteCond     ^(.+)crossdomain.xml    !-f
RewriteRule     ^(.*)$                  /misc/crossdomain.xml [L]

RewriteCond     %{REQUEST_URI}          favicon.ico$
RewriteCond     ^(.+)favicon.ico        !-f 
RewriteRule     ^(.*)$                  /misc/favicon.ico [L]

RewriteCond     %{REQUEST_URI}          robots.txt$
RewriteCond     ^(.+)robots.txt         !-f 
RewriteRule     ^(.*)$                  /misc/robots.txt [L]

© Pro Webmasters or respective owner

Related posts about apache

Related posts about mod-rewrite