您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

网站首页 有时加载不了样式

2025/4/21 3:00:16发布17次查看
做的一个网站,首页有缓存  有时候打开的时候 样式的路径是这样 的   ip地址/css/index.css  首页样式乱了   这个网站一开始用ip:8080访问  绑上域名以后域名访问  但是有时候样式 还是加载的ip的   清除缓存以后  样式的路径换上 域名/css/index.css  首页样式就正常了  首页的缓存采用的是文件缓存
样式的路径采用的是这个函数获得的
function get_http(){ return isset($_server['https']) && strtolower($_server['https']) != 'off' ? 'https://' : 'http://';}function get_domain(){ $protocol = get_http(); if (isset($_server['http_x_forwarded_host'])) { $host = $_server['http_x_forwarded_host']; } elseif (isset($_server['http_host'])) { $host = $_server['http_host']; } else { if (isset($_server['server_port'])) { $port = ':' . $_server['server_port']; if (':80' == $port && 'http://' == $protocol || ':443' == $port && 'https://' == $protocol) { $port = ''; } } else { $port = ''; } if (isset($_server['server_name'])) { $host = $_server['server_name'] . $port; } elseif (isset($_server['server_addr'])) { $host = $_server['server_addr'] . $port; } } return $protocol . $host;}
回复讨论(解决方案) ip地址/css/index.css
这里不是应该ip地址 :8080/css/index.css
ip地址/css/index.css
这里不是应该ip地址 :8080/css/index.css
   有道理
ip地址/css/index.css
这里不是应该ip地址 :8080/css/index.css
 本来应该显示ip:8080 的但是获得是ip 没有带端口,而且现在已经绑定域名了 偶尔还是获得ip 不带端口号  但是清除一下程序的缓存就好了,我想着是不是偶尔服务服务器不稳定 造成获得不了域名呢  那什?情?下?使用ip?
那什?情?下?使用ip?
  这个不确定,网站的首页有10分钟的缓存,会在10分钟过后重新缓存,有时候访问访问着样式就乱了,所以才猜有可能是服务器不稳当 你的网站会是在 http 和 https 间切换吗?
只有在发生切换时才需要产生完整的 url
你 12 行起的,处理端口的代码在什么情况下会执行呢?($_server['http_host'] 总是存在的)
处理端口(port)和处理 host 是平行的,不应该放在 else 分支中
谢谢版主热心回答
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product