CodeIgniter:IP地址与域名上的CSS样式损坏

问题描述 投票:0回答:1

我在我的base_url中有此工作设置

Config.php:

$protocol = is_https() ? "https://" : "http://";
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ""; 

if(is_cli())
{ 
    $config['base_url'] = '';
}
else if( stristr($host, "localhost") !== FALSE || (stristr($host, '192.168.') !== FALSE) || (stristr($host, '127.0.0') !== FALSE) )
{ // if local
    $config['base_url'] = $protocol.$host."/project2/";
}
else
{ // if server
    $allowed_hosts = ['website.com', 'www.website.com']; 
    $config['base_url'] = in_array($host, $allowed_hosts) ? $protocol.$host."/project2/" : "unknown-host.com";
}

$config['index_page'] = '';

$config['uri_protocol'] = 'REQUEST_URI'; // changing to AUTO didn't work too

// possible base_url results are http://www.website.com/project2 and http://192.xxx.xxx.xxx/project2

我的project2 / .htaccess代码:

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

当我在www.website.com/project2上运行站点时-一切都很好,但是当我在192.xxx.xxx.xxx/project2]上运行时-CSS样式损坏

我的css链接如下:

<link rel="stylesheet" href="<?php echo base_url();?>assets/stylesheets/somestyle.css" />

我该如何解决?我需要帮助。谢谢大家!

我在Config.php中有这个有效的base_url设置:$ protocol = is_https()吗? “ https://”:“ http://”; $ host = isset($ _ SERVER ['HTTP_HOST'])吗? $ _SERVER ['HTTP_HOST']:“”; if(is_cli()){$ ...

php .htaccess codeigniter redirect
1个回答
0
投票

对不起,我! 我刚刚更改了.css文件的权限(授予所有权限)

,现在一切正常!谢谢你们在视图源部分专门提供的所有提示。非常感谢!
© www.soinside.com 2019 - 2024. All rights reserved.