WordPress Security with the .htaccess file
Posted on 14th July, 2013 110 Comments
So I showed you how you can help speed up WordPress using a single line of php in your header.php theme file and by adding a few simple lines to your htaccess file. Now lets concentrate on security.
As WordPress is now so widely used (60+ Million users) it has become a bit of a hacking ground for those interested in tinkering in the dark arts. Also because it’s an open source platform the structure is widely available and is well know. So this article is going to help you make your site a whole heap more secure to brute attacks by adding another few lines to your htaccess file.
Firstly you’ll want to protect your wp-config.php as it holds all the server info.
We’ll do this by denying access to everyone. Add this to the bottom of your .htaccess file.
### SECURITY ### # protect wp-config.php <Files wp-config.php> order allow,deny deny from all </Files>
Simply, this snip blocks all access to the file outside of using an ftp client.
Next you’ll want to close the door on people browsing your directories.
# block directory browsing Options All -Indexes
Next but no least, we’ll protect the htaccess file from any attacks.
# protect htaccess <Files ~ "^.*.([Hh][Tt][Aa])"> order allow,deny deny from all satisfy all </Files>
For this file that’s it. Save it and upload it to your /public_html folder on your server.
We are almost done, we just need to do one last thing…
Create another htaccess file. Open notepad and save the document as .htaccess. This one is going to be added to the wp-admin folder, to block anyone trying to login to your site from an outside ip; But will also allow access to the ever important ajax used for eCommmerce sites.
The first order deny,allow is going to block access to your admin area to everyone who doesn’t have a ip that is allowed.
So in a blank .htaccess add this.
If you want to find your ip, google “what is my ip“
#Block access to admin order deny,allow allow from 12.12.12.12 #Find your ip allow from 11.11.11.11 #Add more if needed or delete. deny from all #Block everyone else #Allow Ajax, we're running a business here! <Files admin-ajax.php> Order allow,deny Allow from all Satisfy any </Files>
You can find more on Protecting WordPress Here
If spam is your problem, I have a great fix, that believe it or not actually works and is free.
Comments
To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:
Abinash Mohanty
04th, Feb, 14Thanks for the tips, these are quite helpful. I only have one query about .htaccess under the wp-admin folder. How can we configure for dynamic ip as “what is my ip” shows different addresses when I use my home wifi or at work having different isp. Can’t we map with MAC address? I guess that is permanent right! Let me know, thanks.
WPtricks
08th, Feb, 14For a dynamic ip range you should check out this post which goes into it in a little more depth http://brett.batie.com/software-development/update-htaccess-with-dynamic-dns-ip-address-to-prevent-password-protection/ Or you could add multiple ip’s to the Allow statement.
supsystic team
26th, Jan, 15Hi there!
I find good security plugin and recomend it for you. Most from this functions from this post this plugin has . You can find it from this sites:
http://supsystic.com/
https://wordpress.org/plugins/security-by-supsystic/
Aaron
26th, Jan, 15Suppose if you don’t like poking around your .htaccess file, this is a good option.
VictorAmisp
17th, Oct, 20relevant otitises where the darkness is intersection the caudal enough cialis price in usa Jyeukt sqvcwc cialis 5 mg cialis buy
VictorAmisp
17th, Oct, 20if you’re reversed by restitutive in every way your patient. cialis pilots. Or accountant. or, litigation, may, string bite, raging temper.
VictorAmisp
18th, Oct, 20huge of the decision of this over again difficult diagnostic. prices of cialis muscles dysphagia Р Р† (being very forward surgical) may restore the.
JamesVen
21st, Oct, 20Operate quarter so your form doesn’t seize too [url=https://ciamedusa.com/#]tadalafil price[/url] Zmxroi uvjcbr
JamesVen
21st, Oct, 20cialis a date (inhaled into the life) that when used. [url=https://ciamedusa.com/]cialis pills online india[/url] protocol-and-feel online dispensary canada you slink as regards rigid hypoglycemia.
JamesVen
22nd, Oct, 20unconfined there from with the level serum no surrogate what. [url=https://ciamedusa.com/#]liquid tadalafil[/url] of therapy from one of the simply includes: SouthernГђ ГђВ†s D.
check this link right here now latestbtcnews.com
15th, Nov, 20I together with my buddies came reading the best suggestions found on your web blog and the sudden I had an awful suspicion I never thanked the website owner for those techniques. My men happened to be for that reason joyful to study them and already have actually been making the most of these things. Thanks for actually being really considerate and also for making a choice on these kinds of quality things millions of individuals are really needing to discover. My personal honest regret for not saying thanks to earlier.
Norbertoract
21st, Nov, 20does erectile dysfunction end
[url=https://besterectiledysfunctionpills.com/#]ed meds[/url]
erectile vasectomy
best ed pills
erectile pills without a doctor prescription
Orval Sites
01st, Dec, 20Today, while I was at work, my sister stole my apple ipad and tested to see if it can survive a 25 foot drop, just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views. I know this is entirely off topic but I had to share it with someone!
Mireille Porcello
09th, Dec, 20finest article
Antonia Castaner
16th, Dec, 20Hey very nice web site!! Man .. Beautiful .. Amazing .. I will bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need develop more strategies in this regard, thanks for sharing. . . . . .
Unjury Multivitamin
19th, Dec, 20F*ckin’ tremendous things here. I’m very glad to see your post. Thanks a lot and i’m looking forward to contact you. Will you kindly drop me a mail?
Full Report tgntimes.com
19th, Dec, 20Awesome site you have here but I was wanting to know if you knew of any user discussion forums that cover the same topics talked about in this article? I’d really love to be a part of community where I can get suggestions from other knowledgeable people that share the same interest. If you have any suggestions, please let me know. Thanks a lot!
Orphica Realash Wimpernserum Amazon
20th, Dec, 20Howdy! Do you know if they make any plugins to help with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Thanks!
look at here Aanewshop.com
20th, Dec, 20When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Cheers!
learn the facts here now biz market news
23rd, Dec, 20You completed a number of fine points there. I did a search on the subject and found nearly all persons will have the same opinion with your blog.
look at these guys botapracorrernews.com
23rd, Dec, 20I do enjoy the way you have presented this specific challenge plus it really does provide me a lot of fodder for thought. Nonetheless, coming from what precisely I have seen, I only wish as the actual commentary pack on that folks keep on point and in no way embark on a tirade of some other news du jour. Still, thank you for this fantastic point and even though I can not really concur with the idea in totality, I respect the perspective.
try this out bravenewspaper.com
24th, Dec, 20Very good written story. It will be helpful to anyone who employess it, as well as me. Keep doing what you are doing – looking forward to more posts.
look at this website Breaching News
24th, Dec, 20Howdy! Quick question that’s totally off topic. Do you know how to make your site mobile friendly? My weblog looks weird when viewing from my iphone 4. I’m trying to find a template or plugin that might be able to correct this problem. If you have any suggestions, please share. Thanks!
check my source 0751 sg news
24th, Dec, 20I have been exploring for a little bit for any high quality articles or blog posts on this sort of area . Exploring in Yahoo I at last stumbled upon this website. Reading this information So i’m happy to convey that I have an incredibly good uncanny feeling I discovered exactly what I needed. I most certainly will make sure to do not forget this website and give it a look regularly.
Find Out More Breaching News
25th, Dec, 20Hey I am so grateful I found your website, I really found you by accident, while I was browsing on Aol for something else, Anyways I am here now and would just like to say cheers for a fantastic post and a all round exciting blog (I also love the theme/design), I don’t have time to read it all at the moment but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the excellent job.
you can try this out bomber news
25th, Dec, 20Oh my goodness! an amazing article dude. Thank you Nevertheless I’m experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting identical rss downside? Anybody who is aware of kindly respond. Thnkx
pop over to this site Breaching News
25th, Dec, 20Hola! I’ve been following your weblog for a while now and finally got the bravery to go ahead and give you a shout out from Dallas Texas! Just wanted to say keep up the excellent job!
blog link free town daily news
25th, Dec, 20Very nice post and straight to the point. I don’t know if this is truly the best place to ask but do you people have any thoughts on where to employ some professional writers? Thanks 🙂
company website icetimesmagazine.com
25th, Dec, 20Hello! Do you know if they make any plugins to help with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Many thanks!
Get More Information 7livenews.com
25th, Dec, 20Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your site? My website is in the very same area of interest as yours and my visitors would definitely benefit from some of the information you present here. Please let me know if this okay with you. Many thanks!
next 51kannews.com
25th, Dec, 20You really make it seem so easy along with your presentation but I find this topic to be actually one thing which I believe I would by no means understand. It sort of feels too complex and extremely broad for me. I’m having a look forward to your next put up, I’ll try to get the grasp of it!
click reference 247realnews.com
25th, Dec, 20I’m often to blogging and i really respect your content. The article has actually peaks my interest. I am going to bookmark your website and hold checking for brand new information.
erectile dysfunction icd
29th, Dec, 20icd 10 erectile
how erectile dysfunction affects reproduction
erotikchat
07th, Jan, 21My brother suggested I might like this blog. He used to be totally right. This publish actually made my day. You can not believe just how much time I had spent for this info! Thanks!
hey
13th, Jan, 21Taxi moto line
128 Rue la Boétie
75008 Paris
+33 6 51 612 712
Taxi moto paris
Can I simply say what a relief to find somebody that actually
knows what they’re discussing on the web. You actually know how to bring
a problem to light and make it important. A lot more people should read
this and understand this side of the story. I can’t believe you’re not more popular
because you surely possess the gift.
Maryalice Bighorse
15th, Jan, 21This cup keeps my coffee hot for hours. I should have known about this a long time ago. I enjoy my hot tea or coffee daily but regular mugs or cups don’t keep the beverages hot at all. I don’t like the lukewarm teas or coffee so when I first use this I was blown away. This keeps hot beverages piping hot for at least few hours. It’s amazing! Also, not to forget the color is very vibrant and pretty. I adhered my favorite stickers. This is my daily coffee mug now.
sputnik v vaccine
21st, Jan, 21Would you be excited by exchanging links?
tinder dating
22nd, Jan, 21tindr , what is tinder https://tinderdatingsiteus.com/
Lbgeloks
24th, Jan, 21canadian pharmacies selling viagra to the united states buy viagra online canadian pharmacy viagra for cheap [url=http://genqpviag.com/]viagra 800[/url] ’
Sha Sandlan
25th, Jan, 21What i do not realize is actually how you’re not really much more well-liked than you may be now. You are so intelligent. You realize thus considerably relating to this subject, made me personally consider it from so many varied angles. Its like women and men aren’t fascinated unless it’s one thing to accomplish with Lady gaga! Your own stuffs excellent. Always maintain it up!
Tennie Hibshman
25th, Jan, 21Very well written post. It will be helpful to everyone who employess it, including yours truly :). Keep doing what you are doing – can’r wait to read more posts.
Jasonbag
26th, Jan, 21Доставка алкоголя якутск
Jasonbag
26th, Jan, 21Доставка алкоголя якутск
Jasonbag
26th, Jan, 21Доставка алкоголя якутск
Jdbxeloks
26th, Jan, 21viagra professional sublingual viagra without prescription viagra with priligy [url=http://llviabest.com/]lowest prices on viagra super force 100mg/60mg pills[/url] ’
Jasonbag
26th, Jan, 21Доставка алкоголя якутск
Grover Bolnick
27th, Jan, 21I got this cup as a gift for my wife. She absolutely loves it, she doesn’t go anywhere without it. She uses it for cold brew coffee which can last for hours.
TommyMyday
29th, Jan, 21Заказать прогон хрумером
Jdbxeloks
29th, Jan, 21viagra sale canada viagra onlone viagra vs cialis vs levitra reviews [url=http://llviabest.com/]cheapest viagra australia[/url] ’
TommyMyday
29th, Jan, 21Заказать прогон сайта
TommyMyday
29th, Jan, 21Качественный прогон Хрумером
TommyMyday
30th, Jan, 21Прогон сайта
TommyMyday
30th, Jan, 21прогон хрумер
TommyMyday
30th, Jan, 21Прогон Xrumer
cheap flights
31st, Jan, 21I’m really enjoying the design and layout of your website.
It’s a very easy on the eyes which makes it much more enjoyable for me
to come here and visit more often. Did you hire out a designer to create your theme?
Exceptional work!
cheap flights
01st, Feb, 21I was recommended this blog by my cousin. I am not sure whether this post
is written by him as no one else know such detailed about
my problem. You are incredible! Thanks!
cheap flights
01st, Feb, 21Appreciate the recommendation. Let me try it out.
cheap flights
01st, Feb, 21Woah! I’m really enjoying the template/theme of this blog. It’s
simple, yet effective. A lot of times it’s difficult to get that
“perfect balance” between superb usability and appearance.
I must say you’ve done a superb job with this. Also, the blog loads
super quick for me on Firefox. Exceptional Blog!
Lbgeloks
02nd, Feb, 21/viagra/ viagra for sale easy avilibility of viagra [url=http://genqpviag.com/]viagra for saale[/url] ’
http://tinyurl.com
02nd, Feb, 21Awesome! Its in fact awesome post, I have got much clear
idea regarding from this paragraph.
cheap flights
02nd, Feb, 21It’s going to be finish of mine day, except before end I
am reading this great paragraph to increase my know-how.
http://tinyurl.com/y2os8vy6
03rd, Feb, 21It’s a pity you don’t have a donate button! I’d certainly donate to
this fantastic blog! I guess for now i’ll settle for book-marking
and adding your RSS feed to my Google account. I look forward to fresh updates and will
share this website with my Facebook group. Talk soon!
Ahkdeloks
03rd, Feb, 21online medicine to buy canadadrugs prescription price comparison
Fqhheloks
04th, Feb, 21canadian drugs online pharmacy canadian pharmacy viagra brand pharmacy online store
Jbbveloks
04th, Feb, 21diuretics online rx pharmacy my canadian pharmacy
FvfcUnobe
05th, Feb, 21generic viagra scam viagra from canada supplier viagra greate britain
Lbsxeloks
05th, Feb, 21buying prescription drugs canada sample viagra package diabetes
Kuikdoorm
05th, Feb, 21viagra for sale online best prices for viagra generic viagra without a rx
NncsUnobe
05th, Feb, 21buying viagra from canada viagra not working what to use? drug prices comparison
Jbbveloks
06th, Feb, 21canada prescription plus pharmacy Viagra Professional northwest pharmacy
JbnbPourn
06th, Feb, 21national pharmacies online online pharmacies northwest pharmacy canada
Aqcfnecyanife
07th, Feb, 21cialis online shopping free samples of cialis buying cialis
Aqcfnecyanife
07th, Feb, 21cialis tablets cialis black cialis 200 mg no prescription
KbcxBoth
07th, Feb, 21pharmacy online pills viagra pharmacy 100mg canadia online pharmacy
Lbsxeloks
07th, Feb, 21canada pharmacies without script generic viagra discover card canadian pharmacy no prescription needed
JbnbPourn
07th, Feb, 21canadian pharmacies top best canadian rx drugs from canada with prescription
Ahkdeloks
07th, Feb, 21arthritis canada drug prices ordering prescriptions from canada legally
Kuikdoorm
08th, Feb, 21viagra in the united stater online buying viagra online legal buy viagra no prescription australia
KbcxBoth
08th, Feb, 21try our ed pack online canadian pharmacies ed meds online
Fqhheloks
08th, Feb, 21canadian pharmacies online prescriptions online drugstore pharmacy online canadian pharmacies
shell download
09th, Feb, 21We stumbled over here by a different web page and thought I may as well
check things out. I like what I see so now i am following you.
Look forward to looking over your web page yet again.
FvfcUnobe
09th, Feb, 21viagra overnight delivery in us grapefruit viagra interaction brand name viagra buy
Ahbzeloks
10th, Feb, 21peach cash loans cash net payday loan cheapest bad credit guaranteed approval payday loans direct lender
NncsUnobe
11th, Feb, 21online viagra online drug store viagra what if viagra doesnt work another tablet
Fqbbeloks
11th, Feb, 21payday loans in africa payday advance lansing payday loans in colorado springs co
Jbbneloks
11th, Feb, 21effetti cialis a lungo termine marketing mix cialis cialis overnight delivery
http://tinyurl.com
12th, Feb, 21With havin so much content do you ever run into any issues of plagorism or copyright infringement?
My website has a lot of exclusive content I’ve either authored myself or outsourced but it appears
a lot of it is popping it up all over the web without my
permission. Do you know any techniques to help reduce content from being ripped off?
I’d certainly appreciate it.
Labxeloks
12th, Feb, 21can cialis cause bleeding cialis trial offer cialis 5 mg kaufen
Kbbfdoorm
12th, Feb, 21where can i buy viagra without a prescription where to buy viagra chemist austrlia viagra cipla
Jbbneloks
13th, Feb, 21kann man cialis ohne rezept kaufen daily cialis pills cialis levitra porГіwnanie
FbsgUnobe
13th, Feb, 21buy cialis with american express overnight delivery generic cialis splitting cialis
NbnhUnobe
13th, Feb, 21order viagra online pharmacy where can i buy viagra online in india where to buy generic viagra over the counter
JbnvPourn
13th, Feb, 21long beach payday loans cash loans in lake city fl cash advance usa scam
KvaxBoth
13th, Feb, 21best fast cash loans payday advance gaylord mi cash advance north fort myers
Labxeloks
13th, Feb, 21cuando debo tomar el cialis cialis prix en suisse how long does it take for cialis to leave your system
JbnvPourn
14th, Feb, 21payday loans pitch payday loans killing me edmonton payday loans online
Kbbfdoorm
14th, Feb, 21minute clinic viagra fast acting viagra buy viagra with paypal
KvaxBoth
15th, Feb, 21integrity cash advance 365 cash advance same day cash loan nj
JamesHoact
15th, Feb, 21http://bio-catalyst.com/ – order panmycin
nitrofurantoin online
[url=http://bio-catalyst.com/]myambutol price[/url] buy keftab generic
Ahbzeloks
16th, Feb, 21cash loans credit check cash advance va payday cash loans las vegas
Fqbbeloks
16th, Feb, 21payday loan cathedral city payday advance uk reviews low interest payday loans las vegas
JamesHoact
16th, Feb, 21http://bio-catalyst.com/ – buy ceftin
nitrofurantoin online
[url=http://bio-catalyst.com/]buy minomycin online[/url] buy sumycin generic
FjjuUnobe
28th, Feb, 21how much viagra to take first time viagra ice cream cialis vs viagra cost
ZoilaTStrehl
01st, Mar, 21It’s actually very complicated in this loaded with activity life to listen news on TV,
therefore I just use web for this purpose, and take the latest
information.
Look at my web site – ZoilaTStrehl
Clarkmow
01st, Mar, 21oixff ttd0s t3a5
KndnBoth
01st, Mar, 21tadalafil vs viagra super viagra new viagra commercial actress name
KndnBoth
01st, Mar, 21viagra femenino best natural viagra viagra street value
FjjuUnobe
04th, Mar, 21canadian generic viagra viagra vs sildenafil viagra for men online
More Bonuses PH Times NG
29th, Mar, 21I’m truly enjoying the design and layout of your website. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Excellent work!
zithromax pill
12th, Apr, 21zithromax tab https://zithromaxes.com/ citromax antibiotic drug