/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Making the images folder inaccessible via URL

Hello.

I try this [url]www.freewebhostingarea.com[/url] as my hosting for my project. Everything is fine except that the only directory available for placing the file is the root. It doesn’t have the directory like ‘private_html’ in other hosting in which the files placed their are inaccessible if directly type in the URL.

So I created a new dir in my file manager named ‘members_pic’ and placed some pictures then. But when I typed for example “www.mydomain.freewebhostingarea.com/members_pic/” directly in the URL it will show an index of the contents.

How can I make it inaccessible?

I want this hosting area because its speed is fine for a free hosting.

Thanks.

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@criterion9Feb 04.2010 — Use a .htaccess file if your host is using apache.
Copy linkTweet thisAlerts:
@SrWebDeveloperFeb 04.2010 — In .htaccess:

[COLOR=Blue]Options -Indexes

[/COLOR]


Or...

[COLOR=Blue]IndexIgnore *.gif *.jpg[/COLOR]

The latter is if you only want to hide specific image types, example above prevents all gif's and jpg's from being including in an index listing. Most people use the the first command, but just threw this in here in case you find it useful.

-jim
Copy linkTweet thisAlerts:
@kingdmauthorFeb 05.2010 — Thanks all to your reply.

I'm sad to say but .htaccess is new for me since this is my first time to apply my php practice in a web hosting. I practiced PHP in XAMPP only. So .htaccess is new to me ?

How can I start to do it?
Copy linkTweet thisAlerts:
@MindzaiFeb 05.2010 — Just create a file called .htaccess and put it in a directory. Any Apache directives (such as those posted above) in this file will be applied to the directory the .htaccess file is in.
Copy linkTweet thisAlerts:
@kingdmauthorFeb 05.2010 — Thanks Mindzai.

I now have my .htaccess working.

Is it possible to have the URL won't display the path? What I mean is the only displayed by the URL is the index page even if I'm on other page?
Copy linkTweet thisAlerts:
@DasherFeb 05.2010 — Another simple solution is to create a file; index.htm that just refreshes the page back to your root index file.
Copy linkTweet thisAlerts:
@kingdmauthorFeb 05.2010 — Thanks Dasher, but I think you misunderstood my question. What I mean is say my current position is "www.mydomain.com/admin.php", I don't want this path to be displayed in the URL instead just the "www.mydomain.com/" only.

Is it possible?
Copy linkTweet thisAlerts:
@SrWebDeveloperFeb 05.2010 — That's referred to as [B]URL masking[/B].

You might consider trying to do the Apache Rewrite and PHP page retrieval scripts as detailed here i[COLOR="Red"]f my advice below doesn't fit your needs[/COLOR]:

I'd like to suggest a different approach since I see an admin script is involved. I take it you can tell who is an admin vs. who is not, i.e. either by session/cookie or a database call or whatever. I propose you create an index.php in your document root and at the top add the code you use now to determine if a user is admin or not.

[B]If[/B] they are admin, simply use PHP's "include" to load the admin.php script, [B]else[/B] show your home page or whatever they see when not admin. VERY SIMPLE.

Since its processed server side, and since index.php loads automatically without being specified in the URL, the user's browser address bar always shows only www.yourdomain.com. Just something else to try if you wish.

?

-jim
Copy linkTweet thisAlerts:
@kingdmauthorFeb 05.2010 — Thanks Jim for the detailed reply. You're right about that, I have an include on top of my page and some scripts that can tell admin vs. user via session. Now I know it is called URL masking. Thanks.

I finally learned from it and got it working. ?
Copy linkTweet thisAlerts:
@SrWebDeveloperFeb 07.2010 — Excellent! ?
×

Success!

Help @kingdm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...