Error:
Access to Font at 'http://www.example.com//assets/global/plugins/font-awesome/fonts/fontawesome-webfont.woff2?v=4.4.0' from origin 'http://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com' is therefore not allowed access.
Solution:
<?php
header('Access-Control-Allow-Origin: *');
class Home extends CI_Controller {
public function index()
{
$this->load->view('master');
}
}
?>
I tried this Solution but it not working can you please help me How to resolve it? and How to remove index.php from URL?
Try allowing GET & OPTIONS
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, OPTIONS");
If the above doesn't work, try allowing access to font resources via .htaccess
(for apache) or in nginx server block - add these lines:
# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
or
# nginx config
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
add_header Access-Control-Allow-Origin *;
}
Allowing cross-site scripting may cause security issues, try to adjust your codeigniter options;
- Go to
application/config/config.php
file,
- find
$config['base_url'] = "";
and
place your project folder's path as value.
$config['base_url']="http://localhost/yourProjectFolder/";
Add "Allow from all" in .htaccess
file if it still doesn't work.
<FilesMatch ".(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Allow from all
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
Codeigniter is a cool framework to manipulate PHP, for CORS, you don't need to enable it as it has security implications, just do the following
- open
config.php
,
- look for
$config['base_url'] = "";
- change it to
$config['base_url']="http://localhost/youproject/";
Save and reload your application.
Your good to go
Just we want add 'www' infront of domain name.
Go to application/config/config.php file,
$config['base_url']="http://yourdoamin.com";
Change to
$config['base_url']="http://www.yourdoamin.com";