这样,我就可以用html和php链接到我的文件。因为通过重写url,样式会改变,网站的面貌也会变得丑陋。但是这种方法不是很好,因为它在某些网站上不起作用。
我的代码示例:
<?php $domain = example.com ; $host = $_SERVER['HTTP-HOST'];?>
<link rel="stylesheet" href="<?php echo "http://$host/$domain" ?>style.css" >
发布于 2021-12-25 19:43:10
可能是这样来的吧?
<?php
$domain = 'example.com';
$host = $_SERVER['HTTP_HOST'];
if ($host === 'localhost') {
$host .= "/$domain";
}
?>
<link rel="stylesheet" href="<?php echo "http://$host/" ?>style.css" >UPD:为localhost主机添加了dynamin主机命名。
https://stackoverflow.com/questions/70482294
复制相似问题