ryanreese — 2012-02-26T18:18:08-05:00 — #1
Hello, just got a new website up and running. I use several PHP includes to make sitewide changes easy.
For example I have a settings.php file that just contains my doctype and my <head></head> stuff. I don't want this visible for someone to just go to my site and do ryanreese.us/settings.php (not that people should know it exists)..but still.
What permissions would I have to set for this to happen?
I was unable to think of the correct keywords in a google search.
ralphm — 2012-02-26T19:43:57-05:00 — #2
I would say just bury it a few folders deep that no one will ever fine. All the same, does it really matter if anyone sees the file? They can see the results in the HTML anyhow.
ryanreese — 2012-02-26T19:57:24-05:00 — #3
Burying it a few folders deep only hides the problem. I'd really just prefer to set the file permissions. Knowing that people could get to it nags at me.
logic_earth — 2012-02-26T20:22:58-05:00 — #4
Its not file permissions you want. You have to move it outside of the web root.
ryanreese — 2012-02-26T20:28:57-05:00 — #5
Would I still be able to access the files for PHP includes? Where else do I put those files if not in the web root?
logic_earth — 2012-02-26T22:29:35-05:00 — #6
Yes you would be able to. I don't know how you are setup, but usually "public_html" is the web root, anything above that would be the best.
ryanreese — 2012-02-26T22:50:17-05:00 — #7
Yes there is one level above that :).
Does that sound right? Anyway once I move files over there will I need to change the URLs of my includes to match?
I'm about to go to bed now so I will try it in the morning to either confirm or deny the changing of URLs being needed.
logic_earth — 2012-02-26T22:54:22-05:00 — #8
You will have to change the path...You should not be using URL (http) in PHP includes.
ryanreese — 2012-02-26T22:58:52-05:00 — #9
I'm not using the URL in PHP includes, I'm just doing
That kind of thing. To target the base directory. How do I go even further up then?
logic_earth — 2012-02-26T23:01:14-05:00 — #10
"../" goes up one directory.
ryanreese — 2012-02-26T23:15:13-05:00 — #11
Everything sorted now. Decided to just go in there and do it now. Took all of 5 minutes.
Thanks again, didn't know about that trick to hide files. I learned something today :tup:!