Reputation: 1023
I want to Set Favicon for All files in my site using htaccess ??
Upvotes: 3
Views: 33388
Reputation: 1324
Add this code
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond favicon.ico
RewriteRule .* favicon.ico [L]
If top code is not going to work use this.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule "^(.+)favicon\.ico(|\?.+)$" "/favicon.ico" [PT]
You must put your favicon in public_html directory.
Please DELETE CACHE of your browser or test on a new browser.
I hope it helps.
Upvotes: 1
Reputation: 3280
RewriteEngine on
RewriteBase /
RewriteRule "^(.+)favicon\.ico(|\?.+)$" "/favicon.ico" [PT]
Upvotes: 1
Reputation: 91
Inspired by this thread: Rewriting path for a specific file using htaccess and using the fact that browsers will look for favicon.ico in root of site:
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^favicon.ico path_to_favicon_folder/favicon.ico [L]
Upvotes: 7
Reputation: 967
Rather than specifying a Favicon in htaccess you would be better off using the following META tag within the HEAD area of every page:
<link rel="shortcut icon" href="http://example.com/myicon.ico" />
If this is not possible (perhaps you have a very large static website) you can simply store the file (name it favicon.ico) in your website's root folder (e.g. /public_html/) as browsers will automatically look there first.
Upvotes: 9
Reputation: 77956
Without testing, something along these lines:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond favicon.ico
RewriteRule .* path/to/shared/favicon.ico [L]
Upvotes: 8