Welcome Guest, Not a member yet? Register   Sign In
Document root and public folder
#1
Question 
(This post was last modified: 06-10-2020, 01:36 PM by Didytz.)

Hi,
I developed web app with codeigniter 4 and hosting it on my VPS. During develoent I didnt care much about configuring CI but now when app is almost ready I decided to configure.everything right and I experiance one problem at the begining.

While developing app my document root was public_html, and I was accessing my app like example.com/public/index.php/controler

Also all assets are in CI public directory (/public/css.  /Public/js ...etc)

What I did now is I changed on server document root to CI public folder (instead of public_html which was document root in development), and now I can access my app as planned: example.com/controler (so no public in link).

But my assets are behaving strange while included in head (css) and footer (js). It looks like it only include partial files and not complete because se styles are not applied and others are. I never experiance.this before. When try to visit those files dorectly from browser they load and open, also evertying loads according to Chrome inspect tool.

I experiance this only if I include files with links in this format:
/Css/myfile.css
But if I add public to.this path, like
/Public/Css/myfile.css 
Everthing is workimg and displayed as it should.

To make things even more strange, I can open myfile.css in my browser with any of those two paths (with public in path and also without it). I dont dont under why and how.

I can force my app to work.by including public in path.of.include.links but I feel that.sething is not right and that should be fixed before public relise.
Reply
#2

So your document root path looks like this?

/var/www/example.com/public_html/public

Where public_html contains:
app
public
vendor
writable
(random files)
Reply
#3

(This post was last modified: 06-10-2020, 02:21 PM by Didytz.)

(06-10-2020, 01:58 PM)jreklund Wrote: So your document root path looks like this?

/var/www/example.com/public_html/public

Where public_html contains:
app
public
vendor
writable
(random files)
 
Yes that is correct. Everything is in public_html, but document root is "Public" folder

   

Also to add that I can access files from "public" folder with "public" in link or without it, but I can't access controlers if I include "public" in link, for example this will not work:
example.com/public/Controler1
and this will work:
example.com/Controler1

But I can access CSS files with both of those paths
example.com/public/CSS and also example.com/CSS
Reply
#4

No idea then, you should not be able to access the files both ways.
Reply
#5

(This post was last modified: 06-10-2020, 02:50 PM by Didytz.)

(06-10-2020, 02:19 PM)jreklund Wrote: No idea then, you should not be able to access the files both ways.

I have update which makes this even more stranger.... I open two css files side by side, one with public in path and other without it, and to my surprise there are differences, BUT I don't know from where CI loads two versions.

It seems to me that file without public in link is old version of same file, as one with public in path is one that is really used. I have no idea where is that other file located as I didn't upload two version and only CSS folder is one in public/css

Now I am even more confused, but at least now I know that I am not crazy as I was not able to understand how only part of CSS is loaded, but it was not part but old version without additions made later

   

UPDATE:
While I was waiting for my post to be approved I keep on experimenting and decided to change folder names, and it seems that it fixed the problem. Could it be that there was some kind of cache on server or wherever that go confused after changing document root. Now I changed CSS to MY_CSS and it seems that it fixed problem. But have to test further.
Reply
#6

(This post was last modified: 06-11-2020, 03:24 AM by InsiteFX.)

Yes web browsers will caches the results unless you tell them not to.

To clear the caches in Chrome to this

1) open up chromes developer tools F12.
2 In the top left right click on the arrow partial circle.
3) Click on the bottom Empty Cache and Hard Reload.

That's all there is to it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(06-11-2020, 03:24 AM)InsiteFX Wrote: Yes web browsers will caches the results unless you tell them not to.

To clear the caches in Chrome to this

1) open up chromes developer tools F12.
2 In the top left right click on the arrow partial circle.
3) Click on the bottom Empty Cache and Hard Reload.

That's all there is to it.

Tnx for reply but it is not related to browser cache, as I tested it on few different devices and also in incognito mode which is not keeping cache... It is something to do with server I guess.

Situation now is that I still can access files in "public" folder with public and without it in path, but at least now both versions are the same so it is not breaking my design... I use one without "public" in path.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB