I was working on side project, I need to set headers in .htaccess. But it was causing 500 Internal server error. After googling few minutes, I found that setting headers never throws 500 error. Then I thought it must be mod_headers apache module issue.
I looked at my code again and found that headers line is not wrapped in <If module>
. After wrapping it, it was not affecting. then I checked that if my apache mod_headers module is enable or not. Here below is how we can enable mod_headers
or any module of apache.
Enable any module in Apache
To enable any module in apache enter following command in Terminal:
sudo a2enmod <module_name>
Enable mod_headers
replace by actual module name. Like in our example, I want to enable mod_headers.c module, I will use ‘headers’ (it’s actual name). So command becomes:
sudo a2enmod headers
then, we have to restart apache to make changes. Fire following command to restart apache.
service apache2 restart
Enjoy !!!