CodeIgniter Forums
/public/assets not access after implementing .htaccess to supress index.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: /public/assets not access after implementing .htaccess to supress index.php (/showthread.php?tid=90439)



/public/assets not access after implementing .htaccess to supress index.php - mmhyder - 03-18-2024

Downloaded the fresh new Code Igniter 4 and successfully configured to make controller/function URI work properly. However, Even though the App portion of the website is working as desired any public assets placed in the /public/assets folder is no accessible. I get a 404. I have tried a few solutions i found on the internet but none seems help.


RE: /public/assets not access after implementing .htaccess to supress index.php - InsiteFX - 03-19-2024

That's how I do it works every time.
PHP Code:
<!-- Core theme CSS (includes Bootstrap)-->
 <
link href="<?= base_url('assets/bootstrap/css/bootstrap.css'); ?>" rel="stylesheet">
 <
script src="<?= base_url('assets/fontawesome/js/all.js'); ?>"></script



RE: /public/assets not access after implementing .htaccess to supress index.php - mmhyder - 03-19-2024

(03-19-2024, 12:13 AM)InsiteFX Wrote: That's how I do it works every time.
PHP Code:
<!-- Core theme CSS (includes Bootstrap)-->
 <
link href="<?= base_url('assets/bootstrap/css/bootstrap.css'); ?>" rel="stylesheet">
 <
script src="<?= base_url('assets/fontawesome/js/all.js'); ?>"></script

I have tried base_url('assets/css/my.css') and 
<head>
<base href="<?= base_url();?>">
<link href="assets/css/my.css" rel="stylesheet">l
</head>

nothing is working. Have also tried the default .htaccess that came bundled with CI4 and this 

.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

So far none seems to work.


RE: /public/assets not access after implementing .htaccess to supress index.php - kenjis - 03-19-2024

See https://codeigniter4.github.io/CodeIgniter4/installation/running.html#hosting-with-apache