Engine Multi-Environment Configuration
Users may want multiple environments setup with different engine configurations for each environment, e.g. QA, Prod, Dev, etc.
The following engine configuration files can be setup for different environments:
site-config.xml
application-context.xml
urlrewrite.xml
Setting up an environment
To setup an environment for engine configuration files, do the following:
Create a folder under
data/repos/site/mysite/sandbox/config/engine
calledenv
Inside the folder, create a directory called
myenv
(or whatever you want to call the environment)Copy the configuration file you want to override in the new environment you are setting up, inside your
myenv
folderRemember to commit the files copied so Studio will pick it up.
In the
crafter-setenv.sh
file inTOMCAT/bin
set the following property to desired environment:# -------------------- Configuration variables -------------------- export CRAFTER_ENVIRONMENT=${CRAFTER_ENVIRONMENT:=myenv}
Restart Crafter
Example
Let’s take a look at an example of creating a new environment, called mycustomenv
with the urlrewrite.xml
file overridden in the new environment for a site created using the Website Editorial blueprint:
We’ll create a folder called
env
underdata/repos/site/mysite/sandbox/config/engine
1data/ 2 repos/ 3 sites/ 4 mysite/ 5 sandbox/ 6 config/ 7 engine/ 8 env/
Inside the
env
folder, create a directory calledmycustomenv
We will now create the configuration file for the
urlrewrite.xml
that we want to override in the new environment we are setting up, inside ourmycustomenv
folder:env/ mycustomenv/ urlrewrite.xml
We will redirect the page to
/articles/2017/12/Top Books For Young Women
when the page/articles/2016/12/Top Books For Young Women
is previewed. Copy the following inside theurlrewrite.xml
file.1<?xml version="1.0" encoding="utf-8"?> 2<urlrewrite> 3 <rule> 4 <from>/articles/2016/12/(.*)$</from> 5 <to type="redirect">/articles/2017/12/$1</to> 6 </rule> 7</urlrewrite>
For our example, the folder
articles/2016/12
was copied toarticles/2017
with the page underarticles/2017/12
, modified to display the title as a dupe. This was done so when we click on the page underarticles/2016/12
, we can easily tell that it’s being redirected to the page underarticles/2017/12
. Of course, you can also just look at the url of the page previewed to verify that it was redirected to the right page.Here’s the original page:
Here’s the page we want to be redirected to when previewing the page above:
Remember to commit the files copied so Studio will pick it up.
➜ sandbox git:(master) ✗ git add . ➜ sandbox git:(master) ✗ git commit -m "Add urlrewrite.xml file for mycustomenv"
Open the
crafter-setenv.sh
file inTOMCAT/bin
and set the value ofCRAFTER_ENVIRONMENT
to the environment we setup above (myenv) to make it the active environment:# -------------------- Configuration variables -------------------- export CRAFTER_ENVIRONMENT=${CRAFTER_ENVIRONMENT:=mycustomenv}
Restart Crafter. To verify our newly setup environment, open the
Sidebar
and click on , then selectConfiguration
. Notice that the active environmentmycustomenv
will be displayed on top of the configurations drop-down box and when you select the Engine URL Rewrite Configuration (XML Style), it should display the file we created in one of the previous step:Let’s verify that our urlrewrite.xml is in effect. From the Sidebar, click on Home -> Entertainment -> Top Books For Young Women or, navigate to /articles/2016/12/ and click on Top Books For Young Women.
The preview page should take you to /articles/2017/12/Top Books For Young Women