10 awesome .htaccess hacks for WordPress

by Jean. 252 Comments -

.htaccess, the file which control the Apache webserver, is very useful and allows you to do a lot of things. In this article, let’s see how .htaccess can help you with your WordPress blog, for both security,functionnality and usability.

Warning

When editing or modifying the .htaccess file of your WordPress blog, make sure to always have a backup that you can restore in case of something went wrong.

1 – Redirect WordPress RSS feeds to feedburner with .htaccess

Which blogger doesn’t use feedburner? Sure, feedburner is a very nice service, allowing you to know how many people suscribed to your rss feeds. The only problem is that you must edit your theme files to manually change the rss url. Happilly, there’s a nice hack, using .htaccess, which will make you save a lot of time!
Don’t forget to modify line 6 before applying this code!

# temp redirect wordpress content feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds2.feedburner.com/catswhocode [R=302,NC,L]
</IfModule>

Source: How to redirect WordPress rss feeds to feedburner

2 – Remove /category/ from your WordPress url

By default, WordPress category permalinks are displayed that way:

http://www.catswhocode.com/blog/category/wordpress

As you can see, the category in the url is pretty useless. Here’s how to remove it:
First backup your .htaccess file. Then, open it and append the following line:

RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

Once saved, your categories pages will be displayed like this:

http://www.catswhocode.com/blog/wordpress

Source: How to remove category from your WordPress url

3 – Using browser cache

A very good way to optimize your blog loading time is to force the use of the browser cache. This code will not improve your blog loading time directly, but it will save some work to the server by sending a 304 not modified status when the requested element haven’t been modified.

FileETag MTime Size
<ifmodule mod_expires.c>
  <filesmatch "\.(jpg|gif|png|css|js)$">
       ExpiresActive on
       ExpiresDefault "access plus 1 year"
   </filesmatch>
</ifmodule>

Source: Comment accelerer le temps de chargement de votre blog

4 – Compress static data

Do you know that it is possible to send compressed data to the visitors, which will be decompressed by the client? This code will definitely save you (and your visitor) bandwidth and reduce your pages weight.

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

5 – Redirect Day and name permalinks to /%postname%/

The first thing to do is to login to your WordPress admin, go to Settings → Permalinks and select custom. Fill out the field with /%postname%/.
Your permalinks will now look like the ones on this blog:

http://www.yourblog.com/name-of-the-post

Now we got to redirect all backlinks using the old permalinks structure to the new permalink structure. To do so, you’ll have to edit the .htaccess file, located in WordPress root directory.
Paste the following line in your .htaccess:

RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://www.domain.com/$4

Allright! You just changed your permalinks structure without loosing any backlinks!
Source: Redirect day and name permalinks to postname

6 – How to: Deny comment posting to no referrer requests

Are you sick and tired about the daily amount of spam comments received? Sure, there’s akismet, but here’s a little .htaccess trick to prevent spammers posting on your blog. The fact is that most spammers uses bots comming from nowhere. This code will look for the referrer (the page from where the commentator come from) and will deny commenting if the commentator try to access the wp-comments-post.php file without directly comming from your blog.
Just change the line 4 and specify your blog url there.

RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

Source: How to deny comment posting to no referrer requests

7 – Redirect visitors to a maintenance page

When you’re upgrading your blog, or making theme/design changes, it isn’t a good idea to let people see your blog being tweaked, sometimes with design or code problems, or even worst, security gaps.
The solution is to design a nice “maintenance page” and temporarily redirect your visitors to that page until you finished the maintenance.
Replace maintenance.html (line 2) by the page you’d like to redirect your visitors, and the IP adress on line 3 by your own ip.
Note that a 302 redirection is used, to avoid search engines indexing the maintenance page instead of your real homepage!

RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /maintenance.html [R=302,L]

Source: Comment faire une page d’accueil pour les internautes

8 – Protect your WordPress blog from hotlinking

Hotlinking is the use of an image from one site into a web page belonging to another site. Many bloggers are hotlinked, and have their bandwidth used on another websites. This very helpful code will protect your WordPress blog from hotlinking.

RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]

Source: How to protect your WordPress blog from hotlinking

9 – Allow only your IP adress on the wp-admin directory

Excepted the case of a collaborative blog, only you should be allowed to visit the wp-admin directory. If you have a static IP, this code will do the job.
All you have to do is to enter your static IP adress on line 8. Note that you can add more IPs if needed, by creating a new line with: allow from xx.xx.xxx.xx inside.

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Example Access Control"
AuthType Basic
<LIMIT GET>
order allow, deny
deny from all
allow from xx.xx.xx.xx
</LIMIT>

Source: Protecting the WordPress wp-admin folder

10 – Banning a WordPress Spammer With .htaccess

You know it, spam is very annoying. In the case of a particular person/bot spamming you, you can easily avoid it by blacklisting the IP.
Simply replace the IP adress on line 3 by the spammer’s IP. You can add more spammers by creating a new line with deny from xxx.xx.xxx.xxx inside.

<Limit GET POST>
order allow,deny
deny from 200.49.176.139
allow from all
</Limit>

Source: The easiest way to ban a WordPress spammer

More posts about htaccess

Share this article

 
  • http://www.mytravel.by/ Plantain

    8 – Protect your WordPress blog from hotlinking

    It will be necessary to try necessarily, and that in manual each time to change names of files tires, at the same time and protection against theft of a content.
    Thanks for the information

  • http://www.junglejar.com Christopher Hennis

    Very nice article. Just retweeted it.

  • Pingback: wpressd.com

  • http://www.newsdegeek.com/ Mathieu LESNIAK

    Nice top 10, especially the “Deny comment posting to no referrer requests”. Thanks a lot !

  • http://www.duckonwater.co.uk Duncan Michael-MacGregor

    Great Hacks! im liking the whole saving bandwidth thang – that can be a problem when you got a load of popular blogs on your poor lil’server! ;-)

  • http://www.jamaipanese.com Jamaipanese

    some of these cab be done through plugins but all of them are still very usefull

  • http://hontap.info Tuan Anh

    Thank you for these useful tips.

  • Pingback: 10 hacks .htaccess pour Wordpress | taggle.org

  • http://e-patches.com Embroidery

    Nice list of WP hacks. Thanks a lot !

  • http://www.mentalpurgatory.com Martin Fister

    This is a great list. You do a great job with your blog of really digging into deep aspects of developing a wordpress site and it really has helped me with my blog. I might try and change some of these things.

  • http://www.misternifty.com Brian

    Great tips! I’m going to employ most of them, especially the wp-admin hack.

  • http://www.maigretsblog.com/ Maigret

    Already saved in my bookmarks, thanks a lot ! :cool:

    Just a question for #2 : deleting “category” could be negative for SEO or not ?

  • http://socre.org whaong

    Yes, at least I find good info. Thanks

  • Dan

    Very nice indeed! Thank you!

  • Pingback: Lorissa Shepstone – links for 2009-03-19

  • http://twitter.com/SilverFirefly Silver Firefly

    Hi,

    Thanks for this article, it’s going to be really useful for me, in fact – essential! I’ve dugg this article.

    In response to Comment #7, plugins are bloat. I’d prefer not to use plugins if possible.

  • http://www.werewp.com hd-J

    A great article! Congrats jbj! That’s what I love to read! I am going to add it to wpvote right away!!

  • http://tech.b.chickenandporn.com Allan Clark

    re: #8 (hotlinking), we had a competitor stealing our images. In such cases, the options are:
    1) refuse foreign references, as this solution does
    2) redirect to offensive image to hasten the takedown (immature, funny, but without goatcxe, lacking “oomph”)
    3) redirect to an advertisement for our site

    I opted for #3, I redirected to a lighter-weight image of the site to bring in more clicks. Also, considered swapping out my own reference to that image (only one local ref) and making a permanent redirect for the original reference, with the idea that the discussion plus the 301-redirect to my content actually improves SEO around that subject — the foreign hotlink costs me less bandwidth, but brings in traffic and SEO ranking :)

    • http://twitter.com/gemmaweirs Gemma

      I love the idea of free advertising. ;-) I will have to remember that little tip! Thanks.

  • http://twitter.com/SilverFirefly Silver Firefly

    @Alan Clark,

    I like that solution. I must remember that one. :-)

  • http://smashill.com smashill

    One slick and long list… stumbled it.

  • Pingback: You are now listed on FAQPAL

  • http://www.erfanik.com/farsiblog Kaveh

    Awesome post.. thanks man! just a quick question though. Where should I copy these codes and how can i find this file that you mentioned? Im trying to use the hotlinking code you posted here.

    thanks again…

  • http://www.mcdowellcrook.com/blog/ mcd

    Tried the “Remove /category/ from your WordPress url” and it didn’t work. Should the code be placed in the .htaccess file in the blog/root folder or elsewhere?

  • http://forthelose.org Wordpress Themes

    I’ve always been sorta scared to touvh the htaccess file, but I realized its fine. Just to back it up.

    Anyway, nice post, I like the one with feedburner, probably the most popular one.

  • http://techpp.com Raju

    superb post!! bookmarked and tweeted :) But I particularly don’t like the first hack. it defeats the purpose of feed structure of WordPress.

  • Pingback: 10 Awesome .htaccess Hacks for WordPress — Altitude Development Center

  • Pingback: 10个WordPressçš„.htaccess技巧(强烈推荐) at E-space

  • http://affiliatescorner.com Zulfikar

    Great post very informative. Imma wimp when it comes to messing with the .htaccess but I’v learnt somethings which am gona impelent. Thanks for the advice n tips.

  • http://www.biggle.de Mario

    awesome!
    i found in my htacess old code and remove this… and now is my blog faster then before. Thx for this article!

  • Pingback: Back to the fast Blog | Biggle's Blog

  • http://premiumtheme.info/ Premium Theme Info

    “i found in my htacess old code and remove this… and now is my blog faster then before.” It’s the same to me! Thx!!

  • Pingback: lillbra » Blog Archive » links for 2009-03-19

  • Pingback: WordPress Tutorial How to Add Flickr Photo Widget to Sidebar | Socialseoguide.com

  • http://www.pixel-kingdom.com Dietmar

    Your tipps are extremly helpful to secure/setup my own wordpress blog. Thanx a lot!

  • Pingback: links for 2009-03-20

  • Pingback: 考拉

  • http://www.mfinch.ca/blog/ Online Marketing Blog

    @ Allan i think i am going to do the same thing and show an ad for my site.

    Great list of tips and tricks i am defiantly going to implement a few of them.

  • Pingback: O metodă delicată de a scapa de spam » zoso's blog

  • http://www.netarhia.com Netarhia

    Nice collection of tips. Still, have you tried #4 yourself? It seems not to work (checked with YSlow), components still aren’t gziped.
    As for #6, unfortunately, it’s really easy to set the referrer and user agent, from any server-side script, loads of bots are that advanced. Did you notice any improvement with it?
    Cheers.

  • Pingback: 10个WordPressçš„.htaccess技巧 | digAu☆掘金

  • Pingback: designtick.com

  • Pingback: Web design bookmarks

  • http://www.marketingnewb.com Marketing Newb

    @ Maigret – removing category won’t matter unless you want to rank for that word :)

    Re #3 – is this required if you’re using the WP Super Cache plugin? It seems to do client side caching as well as server side. Not sure though.

  • Pingback: BlogBuzz March 21, 2009

  • Pingback: HowTo use .htaccess with WordPress » WPDesignBlog - wordpress design blog , wordpress themes, themes, design, wp themes, webdesign, templates

  • Pingback: 10个WordPressçš„.htaccess技巧 - cOloR bOx

  • Pingback: Weekend Links - Mar 21, 2009 | OMNINOGGIN

  • Pingback: Top tutorials week ending 03/21/09 | FAQPAL Blog

  • Pingback: 世外桃源 » 10个WordPressçš„.htaccess技巧

  • Pingback: Weekend Roundup #40

  • Pingback: Frühjahrsputz | nodomain.cc

  • http://freewebmasterseotools.com Free Webmaster SEO Tools

    Wow, what a great and detailed guide, very helpful, just subscribed, thanks!

  • Pingback: Cum să scapi de spam « Blog-ul lui CrisM ÅŸi Maria

  • Pingback: WordPress Elite: 10 Awesome .htaccess Edits | boomtchik.com

  • http://www.davidrisley.com David Risley

    What more can I say? Seriously impressed with this post. Thanks.

  • http://www.hindusthanjobs.com hindusthan

    Good Info, I’am try on my blog

  • http://www.itop10.com top 10

    Thanks for the wonderful list.

  • http://wpbloghost.com John Hoff – WpBlogHost

    Nice list of .htaccess codes I think many WordPress (and other) users will like.

    Stumbled your article. Thanks.

  • http://www.dreamsworld.it/emanuele/ Emanuele

    Very useful, thanks! ;-)
    Emanuele

  • Pingback: 10 trucos .htaccess muy útiles para WordPress | Un poco de mucho.com

  • Pingback: ::Digital Shippuden:: » 10 trucos de .htaccess para WordPress

  • http://increase-site-traffic.webmarketingmachine.com/ increase site traffic

    Another great tutorial. Thanks.

  • http://www.0window.com/blog/ Catrin W

    Excellent wordpress hacks collection. I think everyone should at least implement those security hacks, as you never know when your blog will come on hacker’s mind.

  • http://www.spunkyjones.com/ Spunky Jones Blog

    I am assuming that you need %/category/% in your permalink structure active in order to the RewriteRule to function?

  • Pingback: WordPress Elite: 10 Awesome .htaccess Edits | zooped.org

  • http://www.welivethis.com Listen To Hip Hop Music

    This is a very solid article. Its utilization to redirect wordpress rss feeds to feedburner is genius. I also like the idea of using .htaccess to ban spammers. That definitely is going to come in handy!

  • http://www.autoquoter.com AutoQuoter

    Super Article!

    On our site we have comments turned off, however in a dashboard you can still see the huge list of spams trying to get in via wp-comments-form.php and mostly from auto insurance sites, since we’re in that business. Hopefully we put the stop on that.

    Thank you so much, I already add the lines to my .httacess,
    Emil

  • http://www.mintblogger.com Rajeev Edmonds

    Great collection of .htaccess hacks. Hacks about restricting all to wp-admin dir and preventing hot linking is very useful.

  • http://www.acnecaretruth.com Rick

    Excellent article. I was not aware you could do so much in the .htaccess file. I build wordpress sites almost exclusively. Good to know now how much flexibility I have in the .htaccess file.

    Thanks.

  • http://searchengineoptimized.co.cc Seo

    I think there is allready a plugin to redirect standard rss feed to Feedburner rss feed.

  • http://wpbloghost.com John Hoff – WpBlogHost

    Yeah but why would you ever want to use a plugin when there is no need.

    Plugins increase load time of your site and also pose possible security issues to your blog. Last week, someone tried to hack our blog using a security hole in the wp-adverts plugin. We don’t use that plugin, however.

    Whenever you can do something without a plugin, especially if it’s through .htaccess, that’s the way to do it.

  • http://businessmindhacks.com Alex Schleber

    Excellent collection, already tweeted/sent this to everyone I know.

    Re: 2) there is some value to your categories being identified as such to Google, same for Tags if you use them (which I hope you do, ideally with SimpleTags plugin which rules over WordPress’ native tag handling).

    Re: 5) nice trick, of course one should set this up in the way you describe from the beginning…

    Re: 6) I’ve found the YAWASP Plugin to catch 99% of spam via a very simple yet genius method that doesn’t require captchas and doesn’t have the overreach problems that Akismet has (I have Akismet turned off in fact).

  • http://nieruchomosci.iserwer.pl Lokale Gryfino

    Looks you’ve done a great job on .htaccess. I’d like to warn everyone – try it first before you put in on online server. Or backup your previous copy if you’re not 100% sure what you’re doing.

  • http://www.down-sleepingbags.com Down Sleeping Bags

    #6 is awesome! I was wondering how I could possibly stop all the spambot comments easier. I never even thought about the .htaccess file. Duh. Great bit of code. Mucho thanko.

  • Pingback: 10 .htaccess Hacks To Speedup WordPress | One Tip A Day

  • http://blogs.valpo.edu/tiffanyjohnson/ Tiffany Johnson

    Bookmarked! This post was a life saver for getting your blog running well on wordpress. I really liked the redirect feedburner.

  • http://forthelose.org Wordpress Themes

    Yeah I agree. Why use a plugin when everything you need can be found here (or with a quick google search).

  • http://cli.gs/tnomeralcwebdesign Tnomeralc Web Design Toys

    Who needs plugins? You may start to disable some of it and make sa .htaccess tweaks which really comes in handy. Well, How I wish (again) I can do this for blogger platforms.

  • http://timetohealth.com stabilo

    this is a great tutorial. very useful information.
    many thanks to you

  • Pingback: 3 More Plugins To Speedup WordPress | Connected Internet

  • http://www.mentalpurgatory.com Martin Fister

    I hadn’t even put two and two together on the rss feeds. Way to make the most out of it by redirecting to feed burner. This was a great list and I appreciate the suggestions. I hope to see some more soon!

  • http://blog.fazai38.com fazai38

    Wow.. great!!.. thansk for sharing.

  • http://wassupblog.com Sire

    In regards to the feedburner hack do you just replace the http://feeds2.feedburner.com/catswhocode portion with our own code?

  • http://stopsmokingweed.net/ Stop Smoking Weed

    Thanks for the hacks. With regard to #7, can I use it redirect to another site (e.g. http://abc.com and how should I rewrite the code below

    RewriteCond %{REQUEST_URI} !/maintenance.html$

    Is this correct?

    RewriteCond %{REQUEST_URI} !abc.com$

  • http://tech.elementfx.com/blog/ Mezanul

    Thanks for this nice tricks! Especially for the deny comments and hotlinking one!

  • http://www.cosmedical.ca/ Toronto Plastic Surgeon

    re #1 – there’s a plugin for that, which lets you avoid mucking around with (and potentially screwing up) your .htaccess.

  • http://wpbloghost.com John Hoff – WpBlogHost

    Mezanul
    Just remember though, if you stop hotlinking to images on your site you may be denying people a way to find your site. I get traffic from people searching Google and Yahoo Images.

    Toronto Plastic Surgeon
    See my previous comment. Plugins can slow down the load time of your blog and also provide possible security holes. I’ve been on the WP forums for awhile and there are a number of people’s blogs which have been hacked due to security issues with some plugins.

    .htaccess is always the best way to do things. It’s read before your website is even visited.

  • http://FoxNewsBoycott.com FoxNewsBoycott

    #1 would have helped everyone switch their feeds over to the new feeds2 URLs

  • http://www.bewegaleri.com/ bewegaleri

    yeah, i agree with John Hoff. sometimes hotlinked image can drive me some traffics. I don’t care about bandwidth because i host my files in Google (blogspot) :)

  • http://myonlinemoviedownloads.blogspot.com Donald | Download Movies Online

    Thanks. Modifying the htaccess file can be quite challenging. The tips are really useful and I can see right away that I can use a number of them on my blogs.

  • http://bedavam.net Bedava indir

    Nice list of WP hacks. Thanks a lot !

  • http://www.recognizinginnovation.com Plaques

    Fantastic! The category removal from the directories has stumped me. This question might get me railed but it is possible to have an htaccess file in multiple directories on the site correct? I have only use WP for stand alone installations, not to hang on a website.

  • http://www.froumindia.com Indian Forum

    I think some of these hacks are not required. They can be done straight from the settings panel. One hack which I know can be done from settings is hack # 2. It can be done from the permalink structure settings from inside wp-admin.

  • Niazi

    I want to add my own ModRewrite Rule in wordpress blog. Then what should i do ??

    You can also answer me on niazi587 at gmail dot come

  • http://www.pimpmywordpress.com PimpMyWordPress

    Very useful article. Thanks for sharing.

  • http://www.youtractor.com/ Massey Ferguson Tractor

    I’am planning to have my own site.. thanks for this idea. really helps me a lot. I know more blogger are been helped by this topic.

  • http://www.spunkyjones.com/ Spunky Jones Blog Tips

    I just tried the remove /category/ from the URL.
    RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L] on my blog.
    It works, but when you get to any categories, it won’t let me access pages, like /page/2/ without getting a 404 error.

    It appears that I need something to handle the pages.Any suggestion how to handle the following, /page/*/

  • Pingback: Wordpress Blog Services - 10 Exceptional WordPress Hacks

  • http://www.webtlk.com Web Talk

    i already know all this tips. Just beaware of tip number 8 . In fact, you might get penalized by Google. I also think there could be some issue when Google Images try to display your blog pitures in its results…

  • Pingback: Wordpress Links « Andy Widodo - development blog

  • http://www.jaimeattendre.com Emal

    Finally a clear article about htaccess tips !

    2 questions though : is there an easy way to set up a password at the homepage (and the whole blog) ?

    My default htaccess is like this :

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    Where should I insert the code you provide ? Anywhere between the two “#” tags?
    thx

  • http://www.ridex.pl Firany

    Yeah blocking bots is a great way to save a lot of time on comment moderation. Plus you know you won’t miss out on anything important since there hasn’t been one instance in the history that the bot would make a wirthwile comment.

  • http://wpbloghost.com John Hoff – WpBlogHost

    Emal
    You can put it above as the very first item (above the first #) or below the last #, either way will work.

    All the # are, are comments.

    If you’re not familiar with .htaccess, then the easiest way to password protect either a directory or your entire site (i.e. password protect your root) is to set up password protection through your web hosting control panel. Log into your control panel and look for an icon or something name “Password Protect”.

  • Pingback: Most Exceptional WordPress Hacks « Online Free Applications Software Tips Tools Wallpapers

  • http://320volt.com gevv

    Thanks for sharing

  • Pingback: 10 Exceptional WordPress Hacks « the gypsy

  • Pingback: 10 Cool WordPress Hacks | Knowledge Base eDynamo

  • http://www.niharsworld.com/ Nihar

    Thank you very much for this awesom htaccess hacks. I have used 2-3 from the list. WIll try using the rest of them.

  • http://www.retwurl.com ReTwurl Short URL

    Thanks for the wordpress hack list – this will help me setting up things I wanted to.

  • http://smashill.com smashill

    How does the security with those hacks look?

  • http://www.realeflix.com Real Estate Video

    These are definitely some great .htaccess tricks. I have actually used a few of these myself. Another resource that I thoroughly enjoy when it comes to .htaccess tricks is at http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/. You can find a ton of different .htaccess stuff there, from optimization to security.

  • http://www.iamseo.org morris bryant

    awesome tips, thanks a lot.

    you can do the same thing with categories in the permalink sections by using “/.” but it does throw out ome issues with pagination (does the htaccess change work with pagination?)

    protecting from hotlinking images is really great.

    great post!

  • http://freewebmasterseotools.com Free Webmaster SEO Tools

    Awesome stuff, thanks

  • http://www.websitecompanyindia.com Web Design Jaipur

    i already know all this tips. Just beaware of tip number 8 . In fact, you might get penalized by Google. I also think there could be some issue when Google Images try to display your blog pitures in its result

  • Pingback: WordPress World: 50+ excellent WordPress Plugins, articles and resources - Stalkk.ed

  • http://delhifood.com Fast food statistics

    Just like the user before me mentioned, there’s no such a thing as hacking into your email account using nothing more than your email address. Unless it’s an inside job. Whatever you are using for blog.

  • Pingback: WordPress .htaccess Hacks | Web Design

  • http://dofollowsearchengine.com Chris @ DoFollow Backlinks

    Good tips. I only used this in the past to restrict folder access.

  • http://underconstruction tkmk

    #7 sorted me out! I was using a dodgy plugin that was doing some crazy stuff to my website and yet adding a maintenance page is soooo easy!

    Thanks.

  • http://www.kids-television.co.uk Kids Television

    Hey, some good stuff here, I lost 2 hours trying to work out some stuff, found this page and it took me 5 minutes!

    Nice blog too, keep up the good work.

  • http://www.smartadmin.in Sathyavrathan PK

    Thanks much for those awesome tips

  • http://www.sms4share.com/ Funny SMS

    Hi,
    Previously I was using a plugin called “Top Level Cats” to remove “category” from url. When I tried to upgrade WP to the latest version, that plugin started giving problem.

    Thanks to your tip, I have now upgraded to WP 2.7.1 and everything is working perfect. Thank you so much. :)

  • http://freeappleimac.isgreat.org/ Free iMac

    that category hack has saved my ass. However now have to wait for Google to reindex the new pages :S

  • http://www.rutley.co.uk Sam

    Thanks for the great htaccess tips

  • ody

    Hi!, I can´t upload the .htaccess file…
    553 Can’t open that file: Permission denied
    Error: Critical Error

  • http://http//drew3000.net drew3000

    8 and 9 were worth the click alone. thanks.

  • http://www.essex-builders.info Essex Builders

    Yes! The answers I’ve been looking for, I can’t sleep again! thankyou

  • Pingback: Viidar.net » Hjelp! WordPress-databasen min er hacket!

  • http://www.gasolinecreditcards.net gas card

    The tip #8 is is awesome, but I am wondering about the following… besides having ftp access to the server, I only have the Google Analytics stats, I am wondering.. how do you find out without blocking them first, who is using your images, and content? I would much rather see who is using it, as opposed to blocking them first, hehe.

    -Randy

  • http://www.kacamak.org izle

    Yes! The answers I’ve been looking for, I can’t sleep again! thankyou

  • Pingback: Änderung der Wordpress Permalinkstrukur und Verzeichnis - IT-Pulse

  • http://suzyjenkins.deviantart.com/journal/25268259/ Susan

    There are many addons that can do these things, but I still believe using .htaccess is still the best and ONLY way to do these.

  • Pingback: Hacks til WordPress « Tech.BusinessClass.dk

  • Pingback: 10 liens pour étendre Wordpress | Techno-blog.net

  • http://www.mucizebitkiler.net ahmet maranki

    Thank you very much for this awesom htaccess hacks

  • Pingback: WordPress: Plugins, Themes, Tipps & Tricks Collection. | Oberlehrer

  • Pingback: Tips to Speed up Wordpress | Stringer Magazine

  • http://best-resveratrol-supplements.info illmill

    Thanks for the great info on this post. I just found out about the htaccess file, but I didn’t realize you could do so much with it.

  • Pingback: WordPress çš„ 10 个 .htaccess 技巧 | 芒果

  • http://www.geekevaluation.com Geek user

    Very useful tips :).. keep them coming…

  • http://capitolinsuranceagency.com Jon Halvorsen

    Hey Jean-Baptiste,

    Just want to say thank you. My stuff drove me nuts with .htaccess. Please keep it up.

    Once again thanks,
    Jon

  • http://www.pcauthorities.com Jules – Fix PC Errors

    Great tips, just re-tweeted this post. In particular, #4, #8 and #9 are what I need to do today!

    Thanks again,
    Jules

  • Pingback: Die-for plugins » Anime²

  • Pingback: WP .htaccess « YZ WEBDESIGN

  • Pingback: GRINDSTONE MEDIA – 10 Wordpress .htaccess hacks awesomeness

  • Pingback: Wordpressçš„10个.htaccess技巧 | MarK Zhao

  • Pingback: 10 awesome .htaccess hacks for WordPress

  • http://www.iNeedTom.com/ Thomas

    Wow! Jean, Thank you so much for sharing. Found two tricks listed here which I have been looking everywhere for. -Tom

  • Pingback: links for 2009-07-03 « williamlong’s blog

  • Pingback: links for 2009-07-03 |

  • Pingback: A to Z of WordPress .htaccess Hacks | WPShout.com

  • Pingback: 10 Exceptional WordPress Hacks « Web 2.0.

  • http://www.albatol.net Albatol Network

    Thanks for the great tips/tricks in htaccess that we all need it.
    only facing one problem after using couple steps in here.
    all my urls ending with (.htm) is there is any htaccess rule/tip to remove that and just get clean url?
    thanks again

  • Pingback: ijse blog » 10个WordPressçš„.htaccess技巧(强烈推荐)

  • Pingback: 从A到Z!26个用于 Wordpress çš„ .htaccess 规则 - 葡萄树 On The Road — 我只是一个会操作计算机的民工

  • Pingback: 从A到Z!26个用于 Wordpress çš„ .htaccess 规则 | 所以说

  • Pingback: Waking Up To Problems : Thoughtless Banter

  • http://www.shooanswers.com/computers avinash

    hi
    i need your help i am new to wordpress my questions are

    1. is it possible to publish the posts in different directories like if i post it shows
    “www.example.com/your-post” i want to publish the post like “www.example.com/computers/your-post”
    and “www.example.com/internet/your-post”

    2. i install wordpress and i change the permalink settings from “default” to “month and name” and after saving it says “You should update your .htaccess now” but i don’t know where it is and what to update in it.

    i have publish no any posts

    Please help

  • Pingback: 10个WordPressçš„.htaccess技巧(强烈推荐) « ijse blog

  • Pingback: 润物细无声 » WordPress .htaccess çš„10个Hack技巧

  • Tubagus Rusmawan

    hi..

    i am new to wp. if i want to use all the .htaccess hacks, can anyone show me how to write all the .htaccess hacks in just one .htaccess file?

  • http://y-vonneadams.com Dexter Adams

    That’s pretty cool!!

  • Pingback: They keep attacking my WP sites...HELP!

  • Pingback: 30+ Useful WordPress Tutorials

  • Pingback: 10 New Wordpress Hacks - Themeflash : One Stop For All Your Web Resources

  • Pingback: Links and info for beginner blogger | The Old Gamer

  • Pingback: 10个神奇的.htaccess技巧(for WordPress) | 帕兰映像

  • http://techthem.com TechThem

    Great post,
    I really dont know about .htaccess file, but thanks for posting.

  • Pingback: Top 10 ways to stop spam in WordPress

  • Pingback: Top 10 ways to stop spam in WordPress

  • http://www.web-design-talk.co.uk Rob

    Nice list. Really like the protecting your wp-admin directory to a single ip. Bookmarked!

  • Pingback: 卧雪眠云 » 10个WordPressçš„.htaccess技巧

  • http://www.sikis-videolari.net sikiÅŸ

    2 questions though : is there an easy way to set up a password at the homepage (and the whole blog) ?

  • Pingback: 15+ Tips & Resources for Learning and using .htaccess – An Intro for Web Designers | AndySowards.com :: Professional Web Design, Development, Programming Freelancer, Hacks, Downloads, Math and being a Web 2.0 Hipster?

  • Pingback: 15+ Tips & Resources for Learning and using .htaccess – An Intro for Web Designers | AndySowards.com :: Professional Web Design, Development, Programming Freelancer, Hacks, Downloads, Math and being a Web 2.0 Hipster?

  • http://wpbloghost.com/ John Hoff – WP Blog Host

    @ sikiÅŸ – The easiest way to do that if you’re not familiar with .htaccess rules is to simply set up a password protection system through your web hosting control panel.

    Most all hosting companies provide this service. Just a few clicks and you can password protect any directory, including your root.

  • http://www.reliablewebhosting.us/ RWH

    Hey Jean, good list of hacks all put together in a nice and easy way. I wasn’t aware that you could utilize .htaccess file so effectively.

  • Pingback: PHOQU » Blog Archive » Preventing Wordpress Porn via PHP

  • Pingback: WordPress News for 3/31/09 | Projektet II – tankar om ehandel, ledarskap och affärer

  • Pingback: Anointed Support » Blog Archive » Stop spam dead in it’s tracks

  • http://www.karanlikdunya.net sedat

    hi..

    i am new to wp. if i want to use all the .htaccess hacks, can anyone show me how to write all the .htaccess hacks in just one .htaccess file?

  • Pingback: 10 Exceptional WordPress Hacks | 9Tricks.Com - Tips - Tricks - Tutorials

  • Pingback: NamrouD | Upgrade Your Mind ! » 30 Incredibly Useful WordPress Hacks

  • http://www.streetmusician.co.uk kier

    Some great tips. Thanks for sharing

  • http://www.sevismex.com seviÅŸme

    Very nice article, thanks for sharing.

  • Pingback: Top 10 ways to stop spam in WordPress « Doeasyway

  • http://cleopatracostumes.us Cleopatra

    Many thanks for the resources. I find tip #3 – Using Browser Cache particularly useful.

  • http://www.diyaliz.gen.tr diyaliz

    2 questions though : is there an easy way to set up a password at the homepage

  • Pingback: Wordpress Tricks And Hacks » Softloads

  • b00m

    Hi there Jean,

    What if I want to change this:

    …link rel=”stylesheet” href=”http://mydomain.com/wp-content/themes/xmnt/style.css” type=…

    to

    …link rel=”stylesheet” href=”/xmnt/style.css” type=…

    I want to hide the root address…Can .htaccess execute like that?
    If can, can You give me some example how to do it. tnx

  • http://www.sevginehri.gen.tr/ dizi izle

    I want to hide the root address…Can .htaccess execute like that?
    If can, can You give me some example how to do it. tnx

  • http://bourgy.com Steupz

    If you have an established blog already, what are the negatives of switching to postname from year/month/day/postname?

  • Pingback: 10 исключительных WordPress хаков | АртБухта

  • Pingback: Top 10 ways to stop spam in WordPress | meshdairy

  • Pingback: 搜集岛 » 十个WordPressçš„.htaccess技巧

  • Andrew

    Hi Jean,

    I am having problem with WP blog, after upgrade to IE8

    The posts/pages can only opened if the permalinks are set in default.
    Others, will show “The webpage cannot be found” HTTP404

    How to solve? Please

  • http://www.michaelsplace.ca Mike

    Good day,

    I’m new to WordPress and I’m trying to add permalinks so my posts are searchable. Problem – I can’t find .htaccess to open and edit it as per wp-admin instructions. If I try and create a new file .htaccess it tells me it is already there. Is it hidden? It’s probably simple but something is escaping me!!! HELP!

  • Pingback: 3 simple but awesome .htaccess hacks for your Wordpress blog | w3devil

  • Pingback: web20typ_ – Meine Bookmarks vom November 22nd von 16:08 bis 17:59

  • http://cellphonetrackers.org Alex

    Hello, thanks for the post, I have a question.

    When I insert this code to zen-cart .htaccess:

    redirect 301 /odd.html http://www.odddomain.com/new.html

    it did redirect to the new.html, but zencart add certain parameters to the end of the new url which resulted in the show up of the odd.html content while the url is new.html.

    Please help, thanks.

  • GadgetBoyo

    The better way to protect your wp-admin folder with this code

    Order Allow,Deny
    Deny from all

    Allow from all

    allow from xx.xx.xx.xx

    This way when users login they do just see a plain jain ugly page and they get the css loog of the wordpress login.

  • Pingback: WordPressçš„.htaccess设置 » 石头

  • Pingback: 300+ Resources to Help You Become a WordPress Expert | LeVoltz - iPhone Games, Engineering Projects, Wordpress Themes

  • Pingback: 10个WordPressçš„.htaccess技巧-建站指南-站长经验 » By admin » 发布 » sin32

  • http://www.chabadworld.net Chabad

    Some great tips thanks for sharing with us.

  • http://mugur-ionescu.ro/ mugur

    Very helpful tips. Don’t forget 644 to all files, you can be hacked easyly

  • Pingback: 30+ Useful WordPress Tutorials | The Apple Tech Blog

  • http://www.fotolusion.com Sravan

    These really came handy…. kudos!

  • http://www.techylabs.com Rishabh Agarwal

    Indeed Valuable. Thanks for the share :)

  • http://tongstromberg.com Lars Tong Strömberg

    Great post! Quite a few things to use .htaccess for.

    @Alan Clark: Like your developed suggestion for #8 hotlinking. :)

  • http://logoworks.com Clayton Shumway

    Great post! And yes…backing up your code before you start editing, can’t emphasize enough!

  • Pingback: Weekly Links #6 | claudio schwarz – c.schwarz – claudioschwarz.com

  • http://www.techhail.com Samrat P

    very informative post…. But we should always be careful with .htaccess file.. messed up the whole site once!!!

  • Pingback: WP .htaccess | YZ WEBDESIGN

  • Pingback: Wordpress – Themes – Plugins | Tienda virtual online. Diseño de paginas web. Posicionamiento Seo y Sem

  • Pingback: 10个神奇的.htaccess技巧(for WordPress) | Welcome to www.studydog.net

  • Robert

    In Hack 9 it’s not deny,allow it’s allow,deny. If incomming doesn’t match the deny nor allow condition set then the second is followed as allow all if you have deny,allow and deny all if you have allow,deny.

    • http://sahuspilwal.com Sahus Pilwal

      @Robert – Your reply almost gave me a headache! LOL ;) but thanks for the tip on HACK #9

      • Samuel

        Tip #9 is still not fixed. It cannot be in the root, or you will deny access to all but your own IP. It must go in wp-admin/

  • http://www.sksdesigns.com Shannon – SKS Designs

    I am currently using the following permalink structure and am looking to change it through a 301 redirect but cannot find the code that works.

    Currently permalink: /%year%/%monthnum%/%postname%.html
    Future permalink: /%postname%

    Can someone help me?

  • http://www.santosamaru.info santosamaru

    thanks verry much bro for this information, but i need an regex for the baning ip for spammer that like

    if visitor come without reff then go ban it
    if user agent come then ban go ban it
    but if visitor or user agent comes withboth of two list ( the reff and/real user agents name )its must 200

    sorry im still newb ^^ i want to learn please let me know how to to this
    but if i got thats way i will tell you too
    regards

    santosamaru

  • Pingback: Top 10 ways to stop spam in WordPress - IT Shala

  • Pingback: uberVU - social comments

  • http://www.kensfi.com ken

    Wow impressive article!
    Recently, I’ve created a new subdomain (the domain has a wordpress blog on it) and I’ve uploaded some avi files there. I’ve created then an html file with links pointing to these movies.

    The problem is I cannot access these files when I click on the links. Is giving me that message with “Nothing found for …”.

    I guess is related to .htaccess file or / and somehow to wordpress since I did the same thing on another domain with no worpdress on it and it works. Any ideas why this problem?
    Thanks!

  • Pingback: How-to: Secure Your WordPress Blog | janhenrik dot com

  • http://cheapgpsnet.com cahyo

    thanks! i’m new to wordpress and this is just what i’ve been looking for. good luck!

  • Pingback: 10 Exceptional WordPress Hacks « MalarVizhi

  • Pingback: How To Prevent Spam On Wordpress | Radiation-x

  • http://sapitt.com Syafiq Zainal

    Thanks :)
    It’s work like a thunder!
    I try my self with trick number 3 & 4..
    Now my blog load like dedicated sever! :D

  • Pingback: A Complete To-Do List & Plugins for WordPress Site Maintenance | Onextrapixel - Showcasing Web Treats Without A Hitch

  • http://retrohelix.com retro

    I have a question, I installed my blog in its own directory but followed WordPress instructions to move the index so the blog can be accessed from the main index instead of going to the folder, is there a way to redirect people who try to access my installation folder to the index using .htaccess?

  • Pingback: #1 – Optimiser WordPress | Compresser les données via le .htaccess | WordPress Channel

  • http://www.compatibilite.org Astro

    It works when you put into the .htaccess file, make sure you have a static IP

  • http://brittneykernan.com Brittney

    #3 and #4 are MUSTS for graphic heavy sites. Excellent post!

  • http:///www.708media.com Chris

    Very cool stuff. I really like the .htacess that reduces my spam. For the longest time I wondered why I would get a flood of like 20 spam comments however that article had little to no hits.

  • Patricia

    When using a windows server, in this case I have a web.config file, which replaces in that case my htaccess file. How can I incorporate this line to not show the category in the url?
    RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

    I tried this but it does not work:

    Any help would be highly apreciated.

    Thanks,
    Patricia

  • http://mobiledealstop.co.uk/ Valex

    Hi,

    I need some help with my permalinks – actually I’ve decided to change them from /%category%/%postname%/ to /%year%/%monthnum%/%category%/%postname%/

    Could you please tell me how to 301 redirect them.

    Thanks in advance!

  • http://lovepoemsfortheoneyoulove.net/ Mark

    Having always found .htaccess files a bit of a black art (but more obscure), this post contains some really great tips that I will be trying out soon.

    I especially like the ones to do with blocking spammers, as some of our blogs get a ton of comment spam (which Akismet picks up, for the most part, fortunately).

    I also love the idea of replacing hot-linked banners with adverts for your own site. Brilliant!

  • http://produkkesihatan.net khaleed

    This is great tips. Thank you for sharing with us. Especially point no 5, it’s really help me with permalink.

    Just want to share that if anybody experiencing a problem with “404 error not found” in google webmaster tool, right now there is a plugin that can fix it. Just search in the plugin area and you will have a lot of plugin regarding redirecting no need to modified your ht.access anymore.

    Cheers!

  • sara

    not sure why when i use #7 it displays a blank page. I have an image on there with some links to other social sites but none of this displays when using the #7 hack.

    Help please?

  • http://tatchodrom.net Jimmy

    Redirect Day and name permalinks to /%postname%/
    Your code is the only one that has worked for me from the other methods I’ve been trying in the past hour. Thanks heaps!

  • Umar

    How can i hide wordpress page source, so nobody can find i am using WP as back-end .. anyone?

  • http://madebybridge.com Stephen

    Just belatedly came across this article – some great htaccess tips here and I’ve just implemented them on a WordPress site. Thanks Jean-Baptiste! :)

  • http://www.unlock.my Doug Asker

    I am not all that familiar with WordPress. So if I want to use all the .htaccess hacks, can anyone show me how to write all the .htaccess hacks in just one .htaccess file?

  • http://socialadvertising.org Stephen Sanders

    To the comment above, don’t think you block all spammers and hackers, on some level it cannot (and should not) be attempted: You might find a better explanation as to why on:
    http://en.linuxreviews.org/HOWTO_stop_automated_spam-bots_using_.htaccess

  • http://www.jayhands.co.uk jay hands

    I was looking for a way to redirect web visitors to a ‘maintenance page’ while I was doing some update work and I found this post. I am not a coder but popped in your code and it worked. Thanks a lot for taking the time to share your information – by the looks of it you have helped a few people out! Thanks Jay.

  • http://www.aksharweb.com tom jems

    Great tips!!

    I got the .htacess file editing tips and apply this on my site and surprise, it works…

    thanks for this great tips.

  • http://alimese.com.tr Ali Mese

    Great tips and applied already. I guess one should make sure he has a static IP. Thanks for this resource!

  • http://timeforhealthy.com/ Gamatri Michael

    Great tips and applied already. it works… for me
    Thanks for this great tips

  • http://www.techbead.com/ Imtiaz Ali

    Nice hacks for WordPress!

  • Logodesign Bizz

    Everything is very open with a clear description. It was truly informative. Your site is extremely helpful for the beginners as well as for the professionals.Thanks for sharing!
    Custom Logo Design