.htaccess is this the best way to handle shared icons?

Hi,

I have a large number of icons that are used on the many sites that share the same cms backend. (**On the same server)

I want to keep the icons on my main site, but I don’t want users to be aware from which site they icons are coming from, and I don’t want to have to do another dns lookup for their address by linking to them directly style sheets.

Say, in site1.com, site2.com etc I have
css rule


 background: url('/nav/XX_red_beak.png') ;

I have just tested this out and got it working using a .htaccess file in that /nav/ folder like so:

/nav/.htaccess


RewriteEngine on
RewriteRule ^XX_(.*)$ http://mymainsite.com/shared/$1 [QSA,L] 

I am a bit surprised this worked at all, but I wondered if it could be improved, or if you think I am going about this the wrong way.

Obviously I want to retain central control over all the icons (and gmap shadows and things).

Thoughts?

I don’t know if you have access to the apache config, but this sounds like a job for mod_alias

That looks a bit tidier, and hopefully more efficient.

I will take a closer look at that.

I have access to httpd.conf and mod_rewrite is turned on, so after swiftly viewing the docs I will give this a go.

Have you used it for something similar then?

I was thinking I’d change the links in the css files, for example, to

/shared/read_beak.png

then map all requests to /shared/ to a folder out of the doc tree, as the alias instructions suggest.

/var/www/shared/read_beak.png

Thanks a lot.

I haven’t used it myself (yet), but I know mod_autoindex uses it to display icons :slight_smile:

Just a note to say that Alias is a remarkably simple and succinct way to solve that particular problem. I’m so glad I asked, and am very grateful you replied.

I hope I can pass it on some day.

Thanks again!

No problem. Just nominate me for an award next year :wink: :lol: