Enable htaccess on Apache

htaccess also know as hypertext access file available to apache web server and several other known web server software allows us to change configurations on our servers per directory or subdirectory in a decentralized manner. that way we could easily change server configurations per user account without the need to change the actual server config itself. this could save time having to call the techs just to redirect one file to another directory. htaccess can be very helpful especially if you do not have any access to the server configurations however, it can cause some serious performance issues too as it is loaded every time a page is requested in the same directory it resides.

we may enable htaccess by editing our httpd.conf removing the comment on line from
;LoadModule rewrite_module modules/mod_rewrite.so

to
LoadModule rewrite_module modules/mod_rewrite.so

we need to change the AllowOverride directive also from
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>

to
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Satisfy all
</Directory>

You can also rename your .htaccess file by adding the line below on you httpd.conf file
AccessFileName [filename]
example: AccessFileName .configuration

12 Comments
  1. I was looking to enable htaccess in my server, nice guidelines.
    Thanks.

  2. I was looking for a decent introduction to htaccess. You got me on the right track. Thanks!
    Johannes

  3. very useful.. thanks.. :)

  4. Excellent!
    You may want to add that you have 2 entries of AllowOverride you should search and replace :)

  5. Hey! Found it at the right time . Thanks !!

  6. thanks, it was very helpful.

  7. I do not see httpd.conf file anywhere in my root directory. Where can I find

    • C:wampbinapacheapache2.2.22conf is where the file is located in my widows 7 machine

  8. The Options FollowSymLinks is giving a problem so i add + to it to resolve the issue

  9. /etc/apache2/httpd.conf

  10. I tried using using .htaccess in WAMP but its giving some errors. I placed the .htaccess file in my root and edited it with just basic syntax:

    ErrorDocument 404 /errors/notfound.php

    notfound.php just has few basic text (well i was just trying to check if it works or not). When I try to load a page (obviously which is not present) it gives two errors: one that 404 error and:

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    How do I fix this?

  11. Just a comment regarding Apache 2.2

    In addition to the above description, I had to modify the line #226 in my http.conf from:

    AllowOverride None

    to:

    AllowOverride All

    Not sure if it is the right way to do, but i works for me.

    Thanks for this article, clear and helpful.

    Eric

Leave a Reply