Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6029619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:54:47+00:00 2026-05-23T04:54:47+00:00

I have KOHANA_ENV environment var set to DEVELOPMENT for example. Now there is a

  • 0

I have KOHANA_ENV environment var set to DEVELOPMENT for example. Now there is a set of rules I’d like to apply only if that var is set to PRODUCTION (turn on mod_deflate, set expires headers defaults, turn off ETags, etc.), like:

if (KOHANA_ENV == PRODUCTION) {
    // .. do stuff
}

Is there a way to do this on Apache level at all or it’s better to have two conf files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:54:48+00:00Added an answer on May 23, 2026 at 4:54 am

    I do it with the help of the great module mod_macro.

    Let’s say you have in /etc/apache2/envvars (for a Debian-like distribution it’s the place to store apache environnement variables):

    #export KOHANA_ENV=PROD
    export KOHANA_ENV=DEV
    

    Where you [un]coment depending on production or development.

    In the other side you have your VirtualHost, or just a part of it defined with a macro. Macro is the way to write a generic configuration part with some variables. I use it for complete Virtualhosts but here’s an example with just a part of a VirtualHost. We’ll use the environnement variable to decide which macro to use (keyword Use):

    <Virtualhost *:80>
        ServerName foobar.com
        #(...)
        Use EnvStuff_${KOHANA_ENV} /tmp
        #(...)
    

    Here the macro takes an argument (tmp directory path) it’s not an obligation.

    Then you should only define 2 different macro where the environnement variable is part of the macro name EnvStuff_PROD & EnvStuff_DEV:

    <Macro EnvStuff_PROD $tmp>
        <IfModule mod_expires.c>
            # Enable expirations.
            ExpiresActive On
            # Cache all files for 2 weeks after access (A).
            ExpiresDefault A1209600
        </IfModule>
        <IfModule mod_headers.c>
           Header set MyHeader "Hello this is PRODUCTION envirronment. It took %D microseconds for Apache to serve this request."
            # Serve gzip compressed CSS files if they exist and the client accepts gzip.
            RewriteCond %{HTTP:Accept-encoding} gzip
            RewriteCond %{REQUEST_FILENAME}\.gz -s
            RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
            #(...)
        </IfModule>
        php_admin_value upload_tmp_dir $tmp/upload
        #(... other php settings for production)
    </Macro>
    <Macro EnvStuff_DEV $tmp>
        <IfModule mod_expires.c>
            # Enable expirations.
            ExpiresActive Off
        </IfModule>
        <IfModule mod_headers.c>
           Header set MyHeader "Hello this is DEVELOPMENT envirronment. It took %D microseconds for Apache to serve this request."
        </IfModule>
        php_admin_value upload_tmp_dir $tmp/upload
    </Macro>
    

    In these examples you can checkl headers in responses and you’ll see easily if it worked for you.

    Be careful, if the environnement variable is not set well, you’ll get some problems, maybe you can create a macro EnvStuff_ as well 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my bootstrap.php I have the following: if($_SERVER['SERVER_NAME'] == 'localhost') Kohana::$environment = 'development'; else
I have only recently started web programming and I am pretty much amazed that
Have you ever seen any of there error messages? -- SQL Server 2000 Could
I have a website on Kohana and I'm planning to have it multi-language. Now
I have read that 302 HTTP errors are not supposed to appear frequently even
I have this code to send data: function insert_new_image() { var ids = [];
I have registered a domain in iPage.com. But recently i learnt that they are
I have a Kohana 2.3 application. For the logged in/authenticated user I would like
I am using Kohana 3 and I have a controller that extends Kohana_Controller. I
i have a kohana based website and many controllers. I want that some controllers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.