I have a application where i have two versions, Both these versions used different skin. My problem is I need to change favicon based on skin used.
In my application root folder there is only one favicon of one skin.
For 2nd favicon i used path in index.php like
<html>
<head>
<link href="images/skin2/favicon.ico" rel="SHORTCUT ICON"/>
</head>
</html>
And it render favicon of 2nd skin fine, but when i refresh page using Ctrl + F5 then favicon of 1st skin get rendered which is placed in root directory.
Please advise me some solution to solve this problem....
Firefox might be caching the favicon.
Try
Append a query string to the end of the favicon name
<link href="images/skin2/favicon.ico?v=2" rel="SHORTCUT ICON" />
Check to make sure the favicon is accessible. Go to the URL and force a refresh.
http://mydomain/images/skin2/favicon.ico
Ctrl + F5
Rename the favicon file.
Use url rewriting to retrieve favicon.ico from php or asp.net.
You can disable caching and also retrieve the correct icon for the active skin.
RewriteRule ^favicon.ico favicon.php [L]
Then in favicon.php return the correct version
<?php
// add cache control headers here
header('Content-type: image/x-icon');
echo file_get_contents("path-to-skin-icon");
?>
I did some trick and it is working fine, sharing here may help others
<script>
var faviconFolderName = "skin3";
if(skinName == "skin1")
{
faviconFolderName = "skin1";
}else if(skinName == "skin2"){
faviconFolderName = "skin2";
}
$(window).load(function () {
$('head').append('<link href="images/'+faviconFolderName+'/favicon.ico" rel="shortcut icon" type="image/x-icon" />');
});
Related
I want to change the favicon of resources html display pages. I mean when i go to the image url i want to see my icon in the title bar not the icon of the server (in my case XAMPP).
Add this to the <head> of your file:
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
make sure that the href link is correct.
Just put an ICO file named favicon.ico in document root.
A quick test is to open the URL http://my.domain/favicon.ico in a browser; it should display the icon.
Note that the icon file MUST be in document root.
If you can't put the file there physically, you could use Apache's mod_alias to map the file to this URL.
This is done by placing the following line in your server's configuration (httpd.conf file):
alias /favicon.ico /path/to/your/images/directory/favicon.ico
use this
<link rel="icon" type="image/ico" href="images/favicon.ico"/>
Read this Blog Article as well
As the other posters have stated, you need to edit your HTML and in the section, add the line to show the favicon you have uploaded.
If you look at the source for this page, the line defining the favicon is this:
<link rel="shortcut icon" href="//cdn.sstatic.net/stackoverflow/img/favicon.ico?v=6cd6089ee7f6">
but the code stated elsewhere here will also work (<link rel="icon" type="image/x-icon" href="favicon.ico"/>)
Many browsers will automatically look for the favicon.ico in the root of the webserver (as Alex Shesterov wrote in a comment)
I have following code for my header.php file, in the includes folder.
<html>
<head>
<title>Health Mate</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link href="stylesheets/public.css" media="all" rel="stylesheet"/>
</head>
<!-- Some more code-->
</html>
I have pasted favicon.ico in the includes folder itself.Problem is the favicon is not setting up.Also If i redirect user to some site on submit button like yahoo.com . My site is taking favicon of yahoo. Please suggest some solution. Also tell me if favicon needs to be .ico file or it can be .png as well?
You should have necessary path needed to locate your favicon.ico image.
Eg: If your folder is structured this way:
/mysite
/includes
favicon.ico
index.php
If you're going to use it in index.php you should include the necessary path needed like this:
<link rel="icon" href="includes/favicon.ico" type="image/x-icon" />
Note: for checking if your like get the path towards your icon image..
you could check your web page source code using ctrl + u. Then click the href path linked if it displays the image it means your path is correct.
You have to put favicon.ico in to root directory of your website such that anyone can access it by yourdomain.com/favicon.ico. yourdomain.com/includes/favicon.ico will not work without a link tag.
If you can't put the favicon on the root folder for your domain then you have to use this code and change the href attribute to match the path to the favicon relative to the root of your site. i.e. /includes/favicon.ico
<link rel="Shortcut Icon" type="image/ico" href="/includes/favicon.ico">
I would recommend converting the file to an actual .ico using http://www.icoconverter.com/ or some equivalent tool.
I have a big prob. We have a site that was working just fine but I was doing some fine tuning and somewhere along the line i messed things up. possibly in the .htaccess file.
My problem is that my css style sheet doesn't load nor do my images. ahh! They are all there.
I emptied my .htaccess file and deleted my robots.txt just to eliminate any blocking but that didn't fix it.
I validated my css file with The W3C CSS Validation Service and it said:
file not found: http://easybuildingproducts.ca/www.easybuildingproducts.ca/style.css
I feel like it has something to do with the fact that the URL is duplicated. It does that now when i click a link to any of my pages. It should be either or not both those links together. Is it possible a google cached my .htaccess or robots.txt when there was a potential redirect error? Is there a loop happening somewhere?
I was in the midst of making a custom 404 error page when this all went down.
www.easybuildingproducts.ca
Easy fix
<link href="www.easybuildingproducts.castyles/inside.css" rel="stylesheet" type="text/css">
That needs to be either one of the following
<link href="/styles/inside.css" rel="stylesheet" type="text/css">
or
<link href="http://www.easybuildingproducts.ca/styles/inside.css" rel="stylesheet" type="text/css">
I looked at the actual website source to find this example. there are quite a lot like it
Change the href to "/style.css" instead of writing your full domain out. Do the same kind of thing for all other resources that failed to load, too.
This will fix your problem, and it will also make your markup compatible if you decide to migrate to a different dsomain name in the future.
Your resources aren't being loaded (css, js, jquery, etc). Take a look at the screenshot taken from my Chrome Dev Tools > Sources tab:
This is because of your resources' file paths. It is definitely not a good idea to reference all of your resources with "www." in the file path.
Change
<link href="www.easybuildingproducts.castyle.css" rel="stylesheet" type="text/css" />
into
<link href="/castyle.css" rel="stylesheet" type="text/css" />
I'm dealing with some strange behavior that I don't understand.
So if I type:
http://localhost/site/index.php
The http server will return a page with no problems at all, a slash after the index.php will generate a page without any style!
http://localhost/site/index.php/
How can i solve this?
The beneath CSS link isn't working why?
<link rel="stylesheet" type="text/css" href="/css/fonts.css" />
This will work for the slash but if I add something after the slash then I get the all website without styles.
<link rel="stylesheet" type="text/css" href="http://localhost/site/index.php/css/fonts.css" />
EDIT:
All of the requested url are OK after adding the complete path on the href's with this function:
function baseUrl(){
return ("http://".$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']));
}
Anyway, I've added some rules to the .acccess so now I can't type slash after the index.php but if I type something after the slash everything falls apart :(
Check if your <link /> tags href attributes and <img /> tags src attributes are prepended with /:
Bad:
<link rel="stylesheet" type="text/css" href="css/style.css" />
<img src="img/image.png" />
Good:
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<img src="/img/image.png" />
This way you are certain that browser will compute correct path.
It's nothing wrong with Apache. Your document is using relative URLs.
For example, you specify href="myimage.png" instead of /myimage.png
Changing the base URL breaks these relative URLs.
This is likely a problem with absolute and relative paths in your css <link />. Make sure to use an absolute path.
This is probably related to how you define your references to the CSS, images, etc. If they are defined as relative paths, you are probably in essence looking for them in a wrong directory.
You probably have Apache set to ignore the trailing slash (and just serve index.php rather than look for an index file in index.php directory). The client browser however does not know this and is thinking it is referencing something in a directory called index.php and looking for these files relative to that directory.
To correct this, you should either configure Apache not to ignore the trailing slash (and give a proper 404 error), or implement a rewrite rule to clean up the trailing slash.
i have a favicon.ico in my webroot folder according to this piece of code
<link rel="icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
and i use this in my header to make it appear on all the pages.
<?php echo $html->meta('icon', 'favicon.ico'); ?>
The site am working on is -----> this.
What can possibly be wrong ?
It works in 3 pages on IE. On firefox and chrome, it works only for homepage, not others.
Please let me know what i should do.
You ought to just use href="/favicon.ico". If you notice the source of http://www.movend.com/developers/, for example, your reference to favicon.ico resolves to http://www.movend.com/developers/favicon.ico, which is a 404 error page.
If you tried everything above and it still doesn’t work in IE, check your IIS settings if you are using a Windows Server.
Make sure that the HTTP Headers > “Enable content expiration” setting, IS NOT SET to “Expire immediately”