Note that there are some explanatory texts on larger screens.

plurals
  1. PO.htaccess in Multiple Environments
    primarykey
    data
    text
    <p>I know similar questions have been asked before but I haven't found any really specific answers for my situation.</p> <p>I have an ExpressionEngine site running on multiple environments (local, dev, production), and each of those environments needs different .htaccess rules:</p> <p><strong>All Environments</strong></p> <ul> <li><a href="http://expressionengine.com/user_guide/general/remove_index.php.html" rel="noreferrer">Remove index.php</a></li> <li>Set a 404 file</li> <li>Set 301 Redirects</li> </ul> <p><strong>Development</strong></p> <ul> <li>Password Protect with .htpasswd</li> <li>Force HTTPS protocol</li> <li>Prevent search engine indexing with <a href="http://yoast.com/prevent-site-being-indexed/" rel="noreferrer">X-Robots-Tag</a></li> </ul> <p><strong>Production</strong></p> <ul> <li>Force HTTPS protocol</li> <li>Redirect non-www subdomains to www</li> </ul> <p><strong>Local</strong></p> <ul> <li>No unique rules.</li> </ul> <p>I've seen a lot of examples of how you can set specific environments per-module. Like <code>RewriteCond %{REQUEST_HOST} ^dev.myurl.com</code> for the mod_rewrite module, and <a href="http://css-tricks.com/snippets/htaccess/allow-single-url/" rel="noreferrer">tricks like this</a> for .htpasswd requirements.</p> <p>But what I would really prefer is some way to set global environment variables, then re-use those variables in the .htaccess file per-environment. To use pseudo-javascript as an example, something like:</p> <pre><code>var local = 'mysite.local'; var development = 'dev.mysite.com'; var production = 'www.mysite.com'; // Global .htaccess rules if(environment == local){ // Local environment .htaccess rules } if(environment == development){ // Development environment .htaccess rules } if(environment == production){ //Production envirotnment .htaccess rules } </code></pre> <p>This way all of the environment-specific rules are all grouped together, making a really clean file, and only one variable needs to be changed if an environment is changed.</p> <p>I've seen a few references to altering settings in Apache's config files, but obviously that's not a viable option if I'm dealing with 3rd-party hosts.</p> <p>So is this pie-in-the-sky wishful thinking, or can it be done?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload