CodeIgniter Forums
Images and css files not loading on live server - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Images and css files not loading on live server (/showthread.php?tid=76457)

Pages: 1 2


RE: Images and css files not loading on live server - jreklund - 05-16-2020

Hi, thanks for the information. I don't use Apache + PHP anymore, so I can't help you there.
I use Nginx + PHP, and only know how to use different versions there.


RE: Images and css files not loading on live server - InsiteFX - 05-17-2020

Did you try the below?

PHP Code:
<?= base_url('images/imagename.png');?>



RE: Images and css files not loading on live server - Tony.Green - 05-17-2020

Thanks for your reply.
Yes I tried quite a few approaches but as I explained in great detail this is a server side issue because my css and images are being sent back to or served up to the browser as html docs and not in the format that they should be.
I am now looking for what is causing that problem and then a way to resolve the issue.


RE: Images and css files not loading on live server - InsiteFX - 05-17-2020

Check your .htaccess file you can specify things for images etc; In there.


RE: Images and css files not loading on live server - jreklund - 05-17-2020

Oh yeah, I forgot about you can force it that way, you can try to hotfix it with thos.

Code:
# MIME TYPES
<IfModule mod_mime.c>
    # JAVASCRIPT
    AddType application/javascript js jsonp

    # CSS
    AddType text/css css

    # IMAGES
    AddType image/gif gif
    AddType image/jpeg jpg jpeg
    AddType image/png png
</IfModule>



RE: Images and css files not loading on live server - Tony.Green - 05-18-2020

Thanks for this idea!
I will give it a go later when I get back from walking my dog and let you know if it solves the problem I am having.


RE: Images and css files not loading on live server - Tony.Green - 05-18-2020

@jreklund thanks for your suggestion but unfortunately it made no difference on my server. I have raised a ticket with my host to see if they can do anything at their end to resolve my issue and I will keep you updated so that if it gets resolved it may help someone else in a similar situation.


RE: Images and css files not loading on live server - Tony.Green - 05-18-2020

@jreklund great news I have now managed to get this problem resolved with the help of my hosting gurus!!
Apparently on Apache hosting when using the htaccess file needs to have the SetHandler line changed so that it only affects php files and not all files as was happening on my original htaccess setup!!

Here is the modified first lines for the htaccess file:

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-ea-php73-lsphp
</FilesMatch>

I hope this benefits anyone else in a similar situation.

Thanks again for everyone who has replied to this thread I do appreciate all of your help with this.


RE: Images and css files not loading on live server - jreklund - 05-18-2020

Hi, great that you could solve the issue. It's sounds logical that you need to limit that filter. :-)