/    Sign up×
Community /Pin to ProfileBookmark

.htaccess problem

Hello there!
This must be a common issue, but none can help me.
Ia have a website and there is the folder /images, where I store …em… images :p. I call them in index.php through a script in my root, and the script adds a .png watermark logo over them. Pretty standard so far.

Problem is I don’t want the user to be able to load the image, by typing “www.domainname.com/image/imagename.jpg”. I’ve been told to make an .htaccess file, with a “deny”. Although this script get the job done, I cannot load the images from the index.php too.

I believe it’s too common, but it seems I cannot find the proper solution.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@themartySep 29.2010 — you'll have to place a php script outside of that folder and have it load the contents of the image and then output it as an image (with the right headers)
Copy linkTweet thisAlerts:
@BIOSTALLSep 29.2010 — Just to expand on this, you are right in using the .htaccess file. Your .htaccess should reside in the 'images' directory and contain the following:

[CODE]deny from all[/CODE]

Your script that calls the image should then be placed outside of the 'images' directory.

See here for more information on using a .htaccess file to restrict direct access to files.

Hope that helps!
×

Success!

Help @webdeveloper83 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,
)...