Results 1 to 11 of 11
Thread: block access with htaccess
-
02-02-2016, 01:52 PM #1Newbie
- Join Date
- Nov 2015
- Posts
- 8
block access with htaccess
Hello,
I need to block a folder with images with a prohibition that shouldn't be accessed from the web.
The images should be accessed from only one domain.
Is possible to do this task through htaccess?
Suggestion will be appreciated!
Regards
-
02-02-2016, 03:52 PM #2Newbie
- Join Date
- Nov 2015
- Posts
- 8
Please,
I need to block a specific folder setting the .htaccess inside allowing two subdomains to see the images inside the folder, and block all others.
<FilesMatch "\.(jpg|jpeg|png)$">
Allow from subdomain1.domain.com
Allow from subdomain2.domain.com
Deny from all
</FilesMatch>
Any help?
-
02-03-2016, 06:08 AM #3WHT Addict
- Join Date
- Jun 2011
- Posts
- 162
A bit confused, are you trying to restrict your images being used by other websites? Are you referring to hotlink protection? If yes, then you can do it from cpanel, if you are using cpanel as your control panel. If you have wordpress, then it has a hotlink protection plugin as well. Not sure if I understood your requirement clearly.
Also have you mentioned "Order Allow,Deny " anywhere in htaccess?
-
02-09-2016, 03:37 AM #4Newbie
- Join Date
- Nov 2015
- Posts
- 14
Hello Francogas,
Can you please confirm if the server running with nginx reverse proxy? If you just need the external domains not to use the images of the site for their use, you just need to enable hotlink protection from cPanel (If the server is cPanel).
-
02-10-2016, 03:13 AM #5Newbie
- Join Date
- Oct 2015
- Posts
- 11
As tech-home mentioned, If you are using cPanel you can activate Hotlink protection from the control panel for those directories.
documentation.cpanel.net/display/ALD/Hotlink+Protection
and If you are not using cPanel, it is also possible to do it via htaccess by adding the following code:
Code:RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourwebsite.com/.*$ [NC] RewriteRule \.(jpg|jpeg|gif|png|bmp)$ - [F]
-
02-10-2016, 06:38 AM #6Newbie
- Join Date
- Jan 2016
- Posts
- 16
The domain name which you want to access your images is from same server or from different server.
If it is resolving from a different Ip address, you can apply simply .htacess rules to access the images folder only from a specific Ip address like
Order Deny,Allow
allow from XXX.XXX.XXX.XXX
deny from all
-
02-11-2016, 03:45 AM #7Web Hosting Master
- Join Date
- Oct 2007
- Posts
- 2,349
Hi,
This can easily be done using .htaccess codes. You can deny the access of the images directly from all and allow it from one IP of the subdomain you want.
<FilesMatch "\.(jpg|gif|png)$">
order deny,allow
deny from all
allow from <subdomain_IP>
</FilesMatch>www.24x7servermanagement.com
Server Management, Server Security, Server Monitoring.
India's Leading Managed Service Provider !! Skype: techs24x7
-
02-14-2016, 11:35 AM #8Newbie
- Join Date
- Nov 2015
- Posts
- 8
Hi
I'm referring to hotlink protection, but If I use cPanel it put the htaccess in the root of my site, and I need to put the htaccess in the specific folder.
-
02-14-2016, 11:37 AM #9Newbie
- Join Date
- Nov 2015
- Posts
- 8
-
02-14-2016, 11:40 AM #10Newbie
- Join Date
- Nov 2015
- Posts
- 8
-
02-15-2016, 05:22 PM #11Web Hosting Evangelist
- Join Date
- Jan 2012
- Posts
- 527
If you use Apache 2.4 (and not 2.2) then you can easily do something like:
Code:<RequireAll> Require host mydomain.com another.domain.com </RequireAll>
Similar Threads
-
Can I block referrers with .htaccess?
By dtang in forum Programming DiscussionReplies: 2Last Post: 08-18-2006, 07:58 PM -
Block a Webpage with .htaccess
By ariful in forum Web Design and ContentReplies: 9Last Post: 06-28-2006, 07:10 AM -
Restricing access to one IP with .htaccess problems
By lux_interior in forum Hosting Security and TechnologyReplies: 2Last Post: 09-14-2005, 12:03 PM -
Limiting access with .htaccess
By MicroFX in forum Hosting Security and TechnologyReplies: 1Last Post: 06-11-2002, 07:17 PM -
Block IP with .htaccess?
By filburt1 in forum Hosting Security and TechnologyReplies: 2Last Post: 03-07-2002, 09:02 PM