Custom redirects

You can create custom redirects with Magnolia PaaS. This page guides you on doing just that.

You need to:

Clone the template repository

Start with cloning our template repository.

Console
git clone https://gitlab.magnolia-platform.com/developers-artifact/redirects-template.git (1)
rm -Rf .git (2)
mv redirects-template YOUR_REPOSITORY (3)
1 Clones the template from our repository.
2 Removes the .git settings so you can start fresh.
3 Moves the redirects-template to your repository.
The Kubernetes deployment files are provided by Magnolia PaaS and just need to be present in the frontend application folder.

Populate the redirect csv file

Kubernetes deployment files
your_app_folder
├── .gitignore
├── .gitlab-ci.yml
├── README.md
└── src
    └── rules.csv (1)
1 Put your redirects in a rules.csv file.
It must be in csv format (source, target, code). It can contain regexp in the source column.
source,target,code
/source-url,/target-URL,302

Configure the .gitlab-ci.yml file

It’s important that you configure the .gitlab-ci.yml file correctly so that your development changes are picked up and deployed.

Magnolia PaaS automatically picks up the changes when using this approach.
.gitlab-ci.yml
stages:
  - deploy

sync:
  stage: deploy
  image: registry.magnolia-platform.com/developers-artifact/redirects:1.0.0
  environment:
    name: $NAME
  before_script:
    - export KUBECTL_NAMESPACE=$NAME
    - export MAGNOLIA_RELEASE=$NAME
  script:
    - cp /k8s/base/* .
    - envsubst < kustomization-template.yaml > kustomization.yaml ; kustomize build .
    - kubectl -n $NAME apply -k .
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
      variables:
        NAME: integration
    - if: $CI_COMMIT_BRANCH == "master"
      variables:
        NAME: prod
Feedback