[英]base_url() and 403 error in CodeIgniter
In HTML view, css link code looks like this: 在HTML视图中,css链接代码如下所示:
<link href='www.jedendzien.pl/assets/css/style.css' rel='stylesheet'>
but my browser is showing adress with double domain adress 但我的浏览器显示双域地址的地址
www.jedendzien.pl/www.jedendzien.pl/assets/css/style.css
www.jedendzien.pl/www.jedendzien.pl/assets/css/style.css
so i'm getting 403 error. 所以我得到403错误。 I create link by
我创建链接
<link href='<?php echo base_url(); ?>assets/css/style.css' rel='stylesheet'>
and in config.php i'm setting: 在config.php我设置:
$config['base_url'] = 'www.jedendzien.pl/';
In my XAMPP serwer everthing works fine but problem is appearig only on hosting server. 在我的XAMPP serwer everthing工作正常,但问题只出现在托管服务器上。
If i change $config['base_url'] = ''
then adress looks and works ok but i still have problem with 403 error. 如果我改变
$config['base_url'] = ''
然后地址看起来并且工作正常但我仍然有403错误的问题。
My .htaccess in root: 我的.htaccess in root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Change permission of assets/css/style.css to 644 将assets / css / style.css的权限更改为644
Change base url as follows 更改基本URL如下
$config['base_url'] = 'http://www.jedendzien.pl/';
Or If you have a secure url,Then 或者如果你有一个安全的网址,那么
$config['base_url'] = 'https://www.jedendzien.pl/';
Change .htaccess to 将.htaccess更改为
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
对于绝对URL,你应该包括协议,它可能是这样的相对:
<link href='//www.jedendzien.pl/assets/css/style.css' rel='stylesheet'>
Try this .htacces content: 试试这个.htacces内容:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets)
RewriteRule ^(.*)$ /index.php/$1 [L]
Just empty the base_url(); 只需清空base_url(); in config.php file.
在config.php文件中。 And copy the text of .htaccess from the .htaccess file of codeigniter 3 from www.codeigniter.com.
并从www.codeigniter.com复制codeigniter 3的.htaccess文件中的.htaccess文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.