Reputation: 1153
my joomla site has a default htaccess file but it does not contain a section to deny from ipaddresses
There is alot of content in the default htaccess file.
Where can I put my Deny from ipaddresses in this file?
the top of the file has rewriteengine on rewritecond a couple of times
then there is a large section of differing options which appear to be commented out
followed by some more rewritecond lines at the bottom.
Upvotes: 1
Views: 4731
Reputation: 11395
The htaccess mechanism is complicated, and very site-specific. You aren't likely to get an answer that is both simple and reliable. You will have to do learn how your web server and Joomla installation work, and do some experiments.
Articulate clearly what you are trying to accomplish, and why. Is this part of a security plan for your site? Are you trying to block attackers, or block access to everyone except known safe IP addresses? Which IP addresses are you trying to block? Have you thought about what happens if attackers move to a different IP address, not on your block list?
Read the Apache HTTP Server Tutorial: .htaccess files. I've linked to the version for Apache 2.4, but you should read the documentation for the version of Apache you use.
Read the Joomla! Security Checklist documentation. There is an htaccess examples (security) article. It includes a use of deny from
, though probably not the usage you had in mind. You should also take a look through the index of the Security category of the documentation.
You will need to do experiments, so be sure you have a way of trying a change to the .htaccess
file, and reverting to a previous version of the file if the change behaves badly. You could, for example, keep of copy of the original file, and when a change causes problems, upload the original file to the site, overwriting the problematic file.
You will need to decide which changes to make by knowing what web server and what version you are using, and what version of Joomla! you are using.
All that said, I agree with Jon Lin. If you are seeking to deny access from specific IP addresses, add such lines to the top of the .htaccess file, after the comments but before the lines:
########## Begin - RewriteEngine enabled
RewriteEngine On
########## End - RewriteEngine enabled
But be prepared for this to not work the first time, due to the specific details about your environment.
Upvotes: 1
Reputation: 143906
It doesn't really matter where you add the Deny From 1.2.3.4
stuff, but if would probably be more efficient to add them above any mod_rewrite directives, so that those IP addresses would get passed through for a 403 response right away without having the request URI pass through the rewrite engine.
Upvotes: 0