can i force a favicon.ico ?

If that's the same Rails application running behind two you could use rewrite rules per virtual host:

   # first virtual host    RewriteEngine On    RewriteRule ^favicon.ico$ favicon-vh1.ico [L]

   # second virtual host    RewriteEngine On    RewriteRule ^favicon.ico$ favicon-vh2.ico [L]

That's written off the top of my head but you see the idea.

-- fxn

In the configuration of each vhost.

-- fxn

That is not its canonical place, but since we are using rewrite rules you can (tweaking the right-side in the examples I sent before). You can leave them under public if you want as well.

As you know favicon.ico is normally requested by browsers automatically. That is, you don't link to it, except perhaps by a LINK element like this one in the HEAD of your layout:

   <!-- following the guidelines in Favicon - Wikipedia -->    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

Now, if I understand the setup correctly you have two vhosts pointing to the same Rails application. In particular they share the public directory which is the root of the problem.

The browser will still ask for

   http://www.vhost1.com/favicon.ico

and

   您访问的网页不存在!

respectively when they visit any page on those websites.

The point is that you don't even have a favicon.ico under public. You instead have two different .icos somewhere under public and have rewrite rules fool the browser. Each vhost has a different rewrite rule that rewrites internally the URL to serve its corresponding .ico. Perhaps you are not used to this stuff, the browser won't know it is getting something called some other thing in the filsystem of the server, nor that the URL was mangled, /favicon.ico will be retrieved as if existed.

With this setup both .icos are _available_ using direct URLs since the document root is shared, but only the corresponding one will be served as /favicon.ico, which is what we want.

-- fxn

Sorry for the delay, I've been quite busy lately.

The configuration looks OK to me. I have always put my rewrite rules outside the Directory section

   <VirtualHost ...>      <Directory ...>      </Directory>      RewriteRule ...      ...    </VirtualHost>

but if the FCGI dispatcher is being called the rewrite rules are working fine.

Did you tell Apache to reload the configuration?

-- fxn