22

I'm getting in my server error log.

[Mon Jan 27 08:04:06 2014] [alert] [client x.x.x.x] /home/.../public_html/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

And here is my simple .htaccess:

<IfModule mod_rewrite.c>
    Options -MultiViews
    php_flag display_startup_errors on
    php_flag display_errors on
    php_flag html_errors on
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ silex.php/ [L]
</IfModule>

What could be wrong?

3
  • Post your apache2.conf (or httpd.conf, whichever has the most info), please.
    – Nathan C
    Jan 27, 2014 at 14:17
  • Went to /etc/apache2, nothing in httpd.conf Jan 27, 2014 at 14:27
  • @NathanC Sorry forgot to mention I don't know how to copy text from vim to ubuntu clipboard. Looked it up but don't have time to configure right now. I ended up deleting .htaccess. It was actually placed in the wrong directory before getting to where my main web files were located which caused the error. Thanks for the help either way! Jan 27, 2014 at 15:10

3 Answers 3

45

It might be because mod_headers is not enabled. Try running a2enmod headers to enable the module.

2
  • Just enabled and restarted server but still getting the error. It was working before but I was tinkering with the .htaccess for caching. I took out all the previous code I had in there and just left the original (which was working) and now I keep getting this error. Jan 27, 2014 at 13:18
  • 5
    sudo a2enmod headers and then sudo service apache2 restart solved the issue for me on Ubuntu. Oct 20, 2018 at 8:52
7

Enable header module using below command

sudo a2enmod headers

You have to restart your apache once you are done with enabling module

sudo service apache2 restart

1
  • These 2 commands works for me. sudo a2enmod headers. sudo service apache2 restart
    – Alwin Jose
    Aug 25, 2023 at 15:13
3

Did you enable apache mod_headers ?

a2enmod mod_headers

1
  • 1
    Yep just did that based on Nils comment. Didn't solve the issue. Jan 27, 2014 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .