473,508 Members | 2,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

External CSS is working on localhost but not working on online server

6 New Member
I created a website. And the external stylesheet which I have linked to it is working perfectly on my system localhost. But when I upload it to the online server, it doesn't working. Because of this I have to add internal stylesheet which is waste of memory and execution time. I don't know what is the problem, the code is perfectly allright. I don't know how to fix this problem.
Here's the css link to my website:-

Expand|Select|Wrap|Line Numbers
  1. <meta charset="UTF-8">
  2.         <meta name="viewport" content="width=device-width" />
  3.         <link rel="icon" href="icon.png" type="image/png">
  4.         <link rel="stylesheet" type="text/css" href="style.css"/>
  5.         <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
Jan 4 '18 #1
12 34866
Luuk
1,047 Recognized Expert Top Contributor
The problem is probably mixing HTTP and HTTPS.
Make sure that if your page is HTTP, the stylesheet is also HTTP.

Secure websites are not allowed to mix protocols. Everything has to be embedded from a secure server. Browsers will ignore/block HTTP resources on HTTPS pages (with varying degree of strictness).
Jan 6 '18 #2
bhaswanth
6 New Member
Thank you fro your kind response. Can you please explain how to do this....
Jan 17 '18 #3
Luuk
1,047 Recognized Expert Top Contributor
First we have to know how you are going to your webpage, do you use HTTPS? of HTTP.

My guess is you use HTTTP.
If that is true, than change line #5 from 'https://...' to 'http://...'

Normally you should not do that (just change HTTP to HTTPS or the other way around), but this page is also reachable via HTTP, which you can check by typing this address in the address bar of a browser. then browser will respond with a download, and not give an error 404, which means the page exists.
Jan 17 '18 #4
madankarmukta
308 Contributor
Another approach to address this problem is to download the external css and then refer it with href.

Please let us know if this won't help.
Jan 19 '18 #5
GazMathias
228 Recognized Expert New Member
Yet another approach is to use protocol relative URL references whereby you drop the protocol from the link entirely:

<link href="//fonts.googleapis...

The browser will then use the protocol that was used to load your page from your server to request the external resource.

It is useful if you happen to add a certificate later or change from a development to live scenario as you don't have to change anything.

Gaz
Jan 19 '18 #6
Luuk
1,047 Recognized Expert Top Contributor
But in the question was:
"Because of this I have to add internal stylesheet which is waste of memory and execution time."

How much time and memory will be wasted by putting this stylesheet locally?
Jan 20 '18 #7
GazMathias
228 Recognized Expert New Member
Indeed.

Might I also suggest that the OP learn to use the developer console of their chosen browser as no doubt it would have indicated the mixed mode failure and is an invaluable tool regardless.

Gaz
Jan 22 '18 #8
bhaswanth
6 New Member
but that link is provided by google fonts to import external fonts from google. If we remove the protocol from that link, then will it work properly?
Jan 22 '18 #9
GazMathias
228 Recognized Expert New Member
Yes,

It is in the specification, which describes the mechanism browsers should use to fill in the blanks at the start of URLs to save developers retyping the full URL of every resource.

For example you may set an image URL to 'assets/images/someimage.jpg' but the browser will send the request for it to 'http://www.yoursite.com/assets/images/someimage.jpg' because the browser fills in the 'http://www.yoursite.com/' automatically.

However, where possible it's best to use HTTPS everywhere when live.

Gaz
Jan 22 '18 #10
bhaswanth
6 New Member
yeah I think this might be helpful to me. I should try it once.
Thank you
Jan 22 '18 #11
alexhuber
7 New Member
totally agree with Luuk
Feb 7 '18 #12
aki33
1 New Member
Usually this is cache related. Try doing a hard refresh -- CTRL Shift R. Also, if you are using apache2, use the "-i" option. Files are not updating because they are cached. And if you cannot do this, change the href="styles.css" into href="styles.css?v=version2" (that's worked like a charm for my website when I faced the same issue). It would make the server think there is a new file, so then it updates the cache. Or you can always delete the old one and upload the new on.
Feb 12 '18 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4134
by: M P | last post by:
Need help! Whats wrong with my code? My plan is this, I have my IIS5.0 on Server A and then I will use SMTP service of Server B. I already configured IIS to use Server B as its SMTP Server but I...
6
1899
by: sirius | last post by:
I have a simple database in ms access, one table with some 10-15 recordets. When creating web page in asp (vbscript) on my local machine, which displays the contents of access database, everything...
1
1884
by: Brent | last post by:
Hi, I have a C# asp.net app. My validators all worked fine on 2000, and now I moved my app to 2003 and the validators are not working. I added if(!IsValid) return; as a workaround to my...
4
2221
by: MajorTom | last post by:
Hello group, I need to know the best and best responsive way to determinate is a windows form (or the desktop computer) is online (access to internet). I particularly interested for a quick...
5
2732
by: Paul de Goede | last post by:
I set the Response.Filter in my aspnet application but I have noticed that if you do a Server.Transfer that the filter doesn't get called. And in actual fact the response is mostly empty. It seems...
0
1136
by: Viswa Chamarti | last post by:
Hello, Need help in finding a solution. One of our application is not working with application specific error after the upgrade of UDB client with service pack 14. Tried to connect to UDB...
0
825
by: =?Utf-8?B?a21pZGVhcw==?= | last post by:
I'll be running SQL 2005 Standard on a box with Windows Server 2003 Enterprise. This is the database server for a number of websites, running on a separate Windows 2003 server. Do I need one or...
2
1267
by: redblue | last post by:
Hi all, I have a question about making new html page on the server. such as i have a page and have space of heading,body, subject, and file name. if press the button then on the server new file...
7
2784
by: quincy451 | last post by:
drop table . CREATE TABLE . ( NULL , (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , NULL , NULL , (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , (16) COLLATE
8
5076
by: kkshansid | last post by:
external javascript file not working on server <script type="text/javascript" src="../include/common.js"></script> while internal wrking fine <script language="JavaScript"> . . </script> i...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.