问题
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