Some Basic Help with .htaccess File

SMS Text

Throughout past week I came across several people having trouble with .htaccess files. Really, that tech stuff is sometimes frustrating. We have also discussed the 301 redirect and .htaccess file on DailySEOtip last week and found that many people might be using it incorrectly even though it appeared to work (please refer to the comments).

I am not that tech savvy myself – actually I am self-taught, so most probably there are better ways to do things than what and how I am doing. So I am not going to share my own tips here but rather share my list of helpful resources I refer to when I need some basic edits to my .htaccess file really quickly.

.htaccess Generator

.htaccess Editor – I had been seeing many generators but last week stumbled across this one through Lifehacker post and really liked it. It is very well organized and available in a number of languages.

The step-by-step approach is what I liked most about it. You can click through the tasks and add details and the file will be generated below. Here is an example of setting up 301 redirect:

.htaccess Generator

.htaccess Beginners’ Guides

Ann Smarty

Ann Smarty

Brand amd Community Manager at Internet Marketing Ninjas
Ann Smarty is the blogger and community manager at Internet Marketing Ninjas. Ann's expertise in blogging and tools serve as a base for her writing,... Read Full Bio
Ann Smarty
Get the latest news from Search Engine Journal!
We value your privacy! See our policy here.
  • Stuart F

    I would not recommend that generator, in certain situations it creates errors, especially if it is used on wordpress sites.

    Make sure you test quickly and delete if you have problems.

    Also the first ‘basic help’ with an .htaccess file should really be where you place it on your website and with what privileges…

  • haskell

    Tip: When the file is PHP, we can avoid to use .htaccess and replace its content by a redirect:

  • haskell

    Ok, my code was removed by the editor, maybe without the angle brackets?

    lesser than ?php
    header(“Status: 301 Moved Permanently”);
    ?greater than

  • seobag

    Usually I use this tool to generate .htaccess file.
    I think this tool is more powerful.

  • Josh

    Here are two ways I use the .htaccess file and 301:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
    RewriteRule ^(.*)$$1 [R=301,L]


    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.yourdomain\.com$ [NC]
    RewriteRule ^(.*)$$1 [R=301,L]

  • Ann Smarty

    @seobag, thanks for the link, I’ll check it out.

    @everyone, keep the comments coming! the topic seems to cause a lot of misunderstandings

  • Ken Savage

    I’d love to see a guide for us corporate in-house people on how to 301 redirect using Microsoft IIS servers and not having a .htaccess file to use.

    Sure there is the MMC console to create permanent redirects but I had to beg and plead to get temp. access to the console for a huge website migration we did. There’s ISAPI filters out there but are people using them and do they work?

    What do other big websites do for redirects on IIS?

  • Loren Baker, Editor

    We’ve had a lot of requests for this Ken, seems that the Microsoft Shop makes it difficult for managing redirects.

    Readers, any info?

  • Ken Savage

    If it’s easy then I can’t find anyone talking about it.

    If there’s something along the lines of an .htaccess file then I don’t know about it.

    and besides the server admins I talk to often don’t know WTF a 301 redirect is.

    can ya feel my frustration? 🙂

  • pageoneresults

    “How do you handle 301 redirects on Microsoft IIS Servers? Please Reply Here :”

    We’ve been using ISAPI_Rewrite almost since its inception. We’ve worked with Yaroslav at Helicon Tech to fine tune a few things in the process. If your Windows host does not provide rewriting capabilities in 2009, I might suggest finding a new host who does or point your host to this article.

    There are two flavors of ISAPI_Rewrite; the 2.0 httpd.ini method and the 3.0 .htaccess method. Yes, we now have .htaccess on Windows thank to Helicon Tech. We’re doing everything that the folks on Apache have been doing for years. I personally have been working with rewrites on Windows since the turn of the Century. 🙂

    Don’t let your archaic Windows Host hold you back from a very important part of your technical foundation.

  • gabs

    I always just used a load of if statments to include files..

    Stuff like :
    if Request.ServerVariables(“HTTPS”)=”on” OR Request.ServerVariables(“HTTP_HOST”) “” then

    Response.Status=”301 Moved Permanently”
    Response.AddHeader “Location”, “”&LCase(page)
    end if

    You can have a little more fun in asp with 301 via ip and refferal along with case https etc… 🙂

  • Joe Hall

    Generators are great on a fly, but its important to also know how to hand code. When your client already has a custom file built and they ask you to add something here, or change something here, you need to have the skills to make the hand edits. Heres a great little tutorial on hand editing htaccess files like a pro.

  • Richard

    @Ken Savage: I recommend installing ISAPI_Rewrite on your IIS server to make sure your custom 301’s are getting re-directed properly. You can find the software here:

    Current price is $99.00

  • Pasqualon

    Hello all! I’m a reader of this blog quite some time and you’ll find some translations (with credits, of course) from this blog on my blog, if you don’t mind. If there is a problem please tell and I will remove it.

    I’m a Brazilian, so please, excuse my bad English.

    Regarding the Ken Savage request.
    Yes, the ISAP filter works. An our client has implemented as you can see at, they use a .Net platform for their e-commerce running on IIS server, we suggest the ISAPI Rewrite from Hellicon and it works pretty well.

    They do not use all power from .httaccess files, but we managed to clean their URLs and get some keywords on it and even develop a search system! The client is very satisfied with the tool and the server is holding well the charge. (And I’m not a Hellicon seller :D)

    And Ann I love your posts… 😀

  • bavajan

    How to handle 301 redirection on Tomcat Server??

    I have surfed the web like anything to find the answer for this but unfortunately we couldn’t.

    Let me know how to resolve URL Conanicalization issue when iam using TOMCAT Server

  • Jen

    The link to te beginner’s guide is broken. Please can you fix it as I’m definitely interested in a beginner’s guide!!
    Great Post!!

  • Ann Smarty

    Jen, I corrected the link, sorry.