Wednesday, April 02, 2008

 

.htaccess apache configuration

Something really weird happened. I added a .htaccess file to a directory, and each time I tried to access this folder:
- if directly, I got a "500 Internal Server Error"
- indirectly, browsing the hierrarchy through the webbrowser up to this folder, this folder had disappeared !!!

1) stay calm, you're not crazy
2) it means that you may have an error in your .htaccess file
(for instance you're calling a module that's not loaded !)
3) if you have access to apache configuration file (httpd.conf), then write your configurations there.
3.1) first this will speed your server (it won't have to load .htaccess on each page call)
3.2) when you restart apache, you will get an error message that will help you find out the pbm

In my case, I was calling RewriteEngine, when in fact mod_rewrite had not been enabled.
To enable mod_rewrite either do the following:
1) in debian, make a symbolic link to the rewrite module:
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
2) OR directly add the module location ("locate mod_rewrite.so") in httpd.conf:
LoadModule rewrite_module /usr/lib/apache/modules/mod_rewrite.so
#AddModule mod_rewrite.c
3) In any case, restart apache "sudo /etc/init.d/apache2 restart"
Now it should work!

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?