90

I have a htaccess file that it work perfectly on host but when I put it on local ,it shows me this error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

I found this alert in error log file :

[Tue Apr 17 10:02:25 2012] [alert] [client 127.0.0.1] D:/wamp/www/jivan/sql/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

this is my htaccess file code:

  RewriteEngine On
AddDefaultCharset utf-8
RewriteRule ^([0-9-]+)/keyword_show.html$ keyword_show.php?keyword_id=$1
RewriteRule ^page_(.*).html$  page.php?url=$1
RewriteRule ^([0-9-]+)/(.*)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&id=$3&pagenumber=$4
RewriteRule ^([0-9-]+)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&pagenumber=$3
RewriteRule ^([0-9-]+)/(.*).html$ $2.php?advertisement_cat=$1
# cache images and flash content for one month
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

# cache text, css, and javascript files for one month
<FilesMatch ".(js|css|pdf|txt)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

my local server run by wamp and I enabled rewrite module too!!!

so what`s the prob?!!

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
afsane
  • 1,889
  • 6
  • 25
  • 40

6 Answers6

134

the Header directive is in the mod_headers apache module. You need to make sure that module is loaded into the apache server.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Michael Slade
  • 13,802
  • 2
  • 39
  • 44
109

Steps to enable HEADERS modules

$ cd /etc/apache2/mods-available
$ sudo a2enmod headers
$ /etc/init.d/apache2 restart
fedorqui
  • 275,237
  • 103
  • 548
  • 598
Allahbakash.G
  • 1,805
  • 1
  • 15
  • 17
  • 9
    This can be a one-liner: `sudo a2enmod headers && sudo service apache2 restart` (should work on Debian-based distros). – Amal Murali Aug 12 '14 at 17:22
36

On your command line:

Install mod_headers

sudo a2enmod headers

and then restart apache

service apache2 restart
totas
  • 10,288
  • 6
  • 35
  • 32
12

Try this:

<IfModule mod_headers.c> Header set [your_options] </IfModule>

Have you restarted WAMP after installing / enabling?

Scott
  • 285
  • 1
  • 10
6

In an Ubuntu/Debian Machine you can simply run this command:

sudo ln -s /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled/

and should be all set.....

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Amir Koklan
  • 897
  • 2
  • 12
  • 32
3

If you are using WAMP server, do the following

  1. Left click on Wamp tray icon.
  2. Go to Apache -> Apache Modules.
  3. Enable 'headers_module' from the list of modules.
  4. Restart the wamp server or Restart All Services.
Neo
  • 523
  • 7
  • 15