• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

GridPane

  • How it Works
    • Creating Servers
    • Creating Websites
  • Use Cases
  • Pricing
  • Knowledge Base
  • More
    • FAQ
    • Apollo
    • Comparisons
    • Updates
  • Login
  • Free Trial
GridPane >Knowledge Base > Redirection Plugin: How to export redirects and set them via Nginx

Redirection Plugin: How to export redirects and set them via Nginx

Steve B
Updated on 8th December 2020

2 min read
Third-Party Software NoticeOur support team cannot provide support for third-party software and services. However, if you spot an issue with this article please let us know and we will endeavor to bring it up-to-date ASAP.

Intro

Redirect is an excellent plugin that also comes with the functionality to export your redirects as Nginx rewrite rules (which is fancy talk for server-level redirects). You can use the plugin interface to build your redirects, export them, and add them at the server level as an include for better performance.

It’s great for catching URL changes on busy websites, as you can set up Redirection to automatically recreate redirects for posts/pages/custom post types as needed, and then add them in Nginx in batches as time goes by.

Step 1. Export Your Redirects

To export your redirects and add them to your GridPane server directly, log into your website and head to the Redirection page and click on “Import/Export” at the top.

Select “WordPress redirects” and “Nginx rewrite rules” from the dropdowns and click view:

Here you can either download them or simply leave the page open and copy and paste them in step 3.

Step 2. SSH into your server

Please see the following articles to get started:

Generate your SSH Key:

Generate SSH Key on Mac

Generate SSH Key on Windows with Putty

Generate SSH Key on Windows with Windows Subsystem for Linux

Generate SSH Key on Windows with Windows CMD/PowerShell

Add your SSH Key to GridPane:

Add default SSH Keys

Add/Remove an SSH Key to/from an Active GridPane Server

Connect to your server:

Connect to a GridPane server by SSH as Root user.

Step 3. Create redirect-main-context.conf

We now need to create a file called redirect-main-context.conf inside /var/www/site.url/nginx and add your exported redirection code. Create the file with the following command (switching out site.url for your domain name):

nano /var/www/site.url/nginx/redirect-main-context.conf

Next copy and paste your rewrites only (and also the Redirection info as well if you wish – the date may come in handy).

Important: If the rewrites are added inside server { } it result in an Nginx syntax error.

# Created by Redirection
# Tue, 08 Dec 2020 18:33:41 +0000
# Redirection 4.9.2 - https://redirection.me

rewrite ^/test-example$ /sample-page permanent;
rewrite ^/another-example$ https://domain.com permanent;

# End of Redirection

Now Ctrl+O and then press enter to save the file. Then Ctrl+X to exit nano.

Step 4: Check and reload Nginx

Finally, we need to check if the conf files are correct then reload Nginx.

Test your nginx syntax with:

nginx -t

If there are no errors present, reload nginx with the following command:

gp ngx reload

Primary Sidebar

Search the Knowledge Base

  • Provisioning Servers
  • Managing Servers
  • Managing Websites
  • SSL Certificates
  • Server Caching
  • Migrating to GridPane
  • Plugins / Services
  • Security
  • Performance
  • SMTP / Email
  • FAQ
  • Policies

Footer

Quick Links
  • Documentation
  • Status
  • Roadmap
  • Comparisons
  • Updates
  • Facebook Group
Connect With Us
  • (619) 4-SERVER
  • info@gridpane.com
Facebook-f
Twitter
Youtube

GridPane is the world’s first hosting control panel purpose-built for Serious WordPress Practitioners

© Copyright 2017-2021 – GridPane – Run WordPress the Right Way

Terms of Service – Privacy Policy – GDPR
Built with ❤ by S Bell
  • How it Works
    • Creating Servers
    • Creating Websites
  • Use Cases
  • Pricing
  • Knowledge Base
  • More
    • FAQ
    • Apollo
    • Comparisons
    • Updates
  • Login
  • Free Trial