使用 filezilla 或 cpanel 在服务器上上传文件后,css 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7473536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:39:11  来源:igfitidea点击:

css is not working after uploading the file on server with filezilla or cpanel

csscpanelfilezilla

提问by shibly

I have uploaded the file.css file on server with filezilla and also with cpanel. But when i browse the website the css has no impact.

我已经使用 filezilla 和 cpanel 在服务器上上传了 file.css 文件。但是当我浏览网站时,css 没有影响。

I changed: padding-left: 10px; If i see the Page view source i see that the older file is there.

我改变了:padding-left: 10px; 如果我看到页面视图源,我会看到旧文件在那里。

What can be the reason for that ?

那是什么原因呢?

回答by Adam

Try doing a hard refresh. CTRL Shift R. That should force any cached files to clear. Chances are that's the problem, unless the file isn't uploading. If you see the new file listed in Filezilla then it's a cache issue.

尝试进行硬刷新。CTRL Shift R。这应该会强制清除任何缓存的文件。很有可能这就是问题所在,除非文件没有上传。如果您看到 Filezilla 中列出的新文件,那么这是缓存问题。

回答by Nids Barthwal

Have you checked the permission for css files?

您是否检查了 css 文件的权限?

It should be 644 for all files, and 755 for all folders.

所有文件应该是 644,所有文件夹应该是 755。

回答by Hanny

Did you replace/overwrite the existing css file? It sounds like maybe the old one wasn't overwritten - in which case you'll have to do that for the changes to take effect.

您是否替换/覆盖了现有的 css 文件?听起来可能旧的没有被覆盖 - 在这种情况下,您必须这样做才能使更改生效。

Are you using a CMS? Some of them have Cache features where it may take time for those changes to be reflected unless you hard refresh.

您使用的是 CMS 吗?其中一些具有缓存功能,除非您硬刷新,否则这些更改可能需要时间才能反映出来。

回答by Cory Redmond

http://httpd.apache.org/docs/2.2/programs/htcacheclean.html

http://httpd.apache.org/docs/2.2/programs/htcacheclean.html

If you are using apache2 this is amazing, use the "-i" option, the reason the files dont update is because they are cached, if you cant do this you can always change the href="styles.css" into href="styles.css?v=version2" it makes the server think that there is a new file, so then it updates the cache

如果您使用的是 apache2 这很棒,请使用“-i”选项,文件不更新的原因是因为它们被缓存,如果您不能这样做,您可以随时将 href="styles.css" 更改为 href=" style.css?v=version2" 它让服务器认为有一个新文件,所以它更新缓存

回答by Mwiti

I changed the name of the .css file, deleted the old one from the server, reuploaded and directed the html to that newly named and uploaded css file. Worked like a charm for some reason.

我更改了 .css 文件的名称,从服务器中删除了旧文件,重新上传并将 html 定向到新命名和上传的 css 文件。出于某种原因,它像魅力一样工作。

回答by Prashant Rajpoot

First try to clear the cache. If nothing happens then link your CSS like this:

首先尝试清除缓存。如果没有任何反应,那么像这样链接你的 CSS:

<link rel="stylesheet" type="text/css" href="style.css?v=0.001">

It should help.

它应该有帮助。