base_url() and 403 error in CodeIgniter

牧云@^-^@ 提交于 2021-02-09 08:16:23

问题


In HTML view, css link code looks like this:

<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

so i'm getting 403 error. I create link by

<link href='<?php echo base_url(); ?>assets/css/style.css' rel='stylesheet'>

and in config.php i'm setting:

$config['base_url'] = 'www.jedendzien.pl/';

In my XAMPP serwer everthing works fine but problem is appearig only on hosting server.

If i change $config['base_url'] = '' then adress looks and works ok but i still have problem with 403 error.

My .htaccess in root:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

回答1:


Change permission of assets/css/style.css to 644

Change base url as follows

$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

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]



回答2:


For absolute url you should include protocol, it may be relative like this:

<link href='//www.jedendzien.pl/assets/css/style.css' rel='stylesheet'>



回答3:


Try this .htacces content:

RewriteEngine on
RewriteCond $1 !^(index\.php|assets)
RewriteRule ^(.*)$ /index.php/$1 [L]



回答4:


Just empty the base_url(); in config.php file. And copy the text of .htaccess from the .htaccess file of codeigniter 3 from www.codeigniter.com.



来源:https://stackoverflow.com/questions/28881728/base-url-and-403-error-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!