1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Apache: edit to .conf file produces “Invalid command 'Header'”

Discussion in 'Apache' started by SRD, Dec 31, 2015.

  1. #1
    In Magento CE, I'd like to install an add-on to Extendware Page Cache called Lightening Cache.

    It requires editing the Apache configuration inside the virtual host definition for the site, by adding:

    RewriteEngine On
    RewriteMap ewpchash prg:/home/.../shell/extendware/ewpagecache/apache/md5.php
    
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{REQUEST_URI} !\.(js|css|png|jpg|jpeg|ico|gif)$ [NC]
    RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} !-f
    RewriteCond ${ewpchash:%{HTTPS};~;%{HTTP_HOST};~;%{REQUEST_URI};~;%{QUERY_STRING};~;%{HTTP:Cookie};~;%{SCRIPT_FILENAME};~;%{REMOTE_ADDR};~;%{HTTP_USER_AGENT}} -f
    RewriteRule ^(.*)$ ${ewpchash:%{HTTPS};~;%{HTTP_HOST};~;%{REQUEST_URI};~;%{QUERY_STRING};~;%{HTTP:Cookie};~;%{SCRIPT_FILENAME};~;%{REMOTE_ADDR};~;%{HTTP_USER_AGENT}} [NC,L]
    <FilesMatch "\.(html)$">
    Header unset Cache-Control
    Header unset Expires
    Header append Expires "Thu, 19 Nov 1981 08:52:00 GMT"
    Header append Cache-Control "must-revalidate"
    </FilesMatch>
    Code (markup):
    I have added this to the bottom of /etc/apache2/sites-enabled/site.conf

    When I run the command "apachectl graceful', I receive the error:

    Site is running Apache 2.4

    Have I done something wrong?
     
    SRD, Dec 31, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Aren't those entries for a .htaccess file, not the conf-file?
     
    PoPSiCLe, Jan 1, 2016 IP
  3. SRD

    SRD Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    That's what I thought too, but the application instructions are quite explicit:

    To use the Advanced mode you must ensure to have purchased the lightening cache addon. If you do not have this, then the simple mode will be used. You must be using apache in order to use the advanced mode and you must be able to modify the apache configuration.. To use the advanced mode you need to add the following rewrite rule in your apache configuration inside the virtual host definition for your site. Important: This is to be added to the virtual host section of the apache config and not your htaccess file. You or your host must be able / willing to modify the file.

    RewriteEngine On
    RewriteMap ewpchash prg:[Magento root path]/shell/extendware/ewpagecache/apache/md5.php
    
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{REQUEST_URI} !\.(js|css|png|jpg|jpeg|ico|gif)$ [NC]
    RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} !-f
    RewriteCond ${ewpchash:%{HTTPS};~;%{HTTP_HOST};~;%{REQUEST_URI};~;%{QUERY_STRING};~;%{HTTP:Cookie};~;%{SCRIPT_FILENAME};~;%{REMOTE_ADDR};~;%{HTTP_USER_AGENT}} -f
    RewriteRule ^(.*)$ ${ewpchash:%{HTTPS};~;%{HTTP_HOST};~;%{REQUEST_URI};~;%{QUERY_STRING};~;%{HTTP:Cookie};~;%{SCRIPT_FILENAME};~;%{REMOTE_ADDR};~;%{HTTP_USER_AGENT}} [NC,L]
    <FilesMatch "\.(html)$">
     Header unset Cache-Control
     Header unset Expires
     Header append Expires "Thu, 19 Nov 1981 08:52:00 GMT"
     Header append Cache-Control "must-revalidate"
    </FilesMatch>
    Code (markup):
    Important: you need to replace the text [Magento root path] with the root file path where Magento is installed. The file at [Magento root path]/shell/extendware/ewpagecache/apache/md5.php must be executable (cmhod +x) and the first line of the file #!/usr/bin/php must correctly point to a php interpreter. This has been tested with apache 2.4. Not guaranteed to work on 2.2
     
    SRD, Jan 1, 2016 IP
  4. SRD

    SRD Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    Turns out I needed to enable mod_headers.
     
    SRD, Jan 1, 2016 IP