How to Add a Redirect in Nginx on a Plesk Server

Learn how to set up fast, server-level redirects on a Plesk server using Nginx “Additional nginx directives,” including full-domain redirects to acme.com, single-URL redirects, and common gotchas to avoid.

Table of Contents

If you manage sites on a Plesk server, chances are you’ll eventually need to redirect one domain to another—maybe after a rebrand, a site consolidation, or a migration. On Plesk with Nginx enabled, the cleanest way to do this is using Additional nginx directives for the domain you want to redirect from.

In this guide, we’ll walk through:

  • Redirecting an entire domain to acme.com
  • A variant for redirecting a single URL
  • Tips and common gotchas

All examples will use acme.com as the target site.


How Plesk Uses Nginx (Quick Overview)

On a typical Plesk server:

  • Nginx runs as a reverse proxy in front of Apache.
  • Requests hit Nginx first.
  • “Additional nginx directives” let you inject your own Nginx config into that domain’s vhost.

Because redirects happen very early in the request flow, doing them at the Nginx layer is efficient and avoids unnecessary PHP/Apache overhead.


Redirect an Entire Domain to acme.com

Goal

Any request to this domain (say, oldsite.com) should 301 redirect to https://acme.com, preserving the path and query string.

Example:

  • http://oldsite.com/abouthttps://acme.com/about
  • https://oldsite.com/products?id=123https://acme.com/products?id=123

Step-by-Step in Plesk

  1. Log in to Plesk
  2. Go to Websites & Domains
  3. Click the domain you want to redirect from
    (for example, oldsite.com).
  4. Click Apache & nginx Settings
  5. Scroll down to Additional nginx directives
  6. Paste the following snippet:
  7. Click OK or Apply to save changes.

That’s it. Once Plesk rebuilds the config, any request to that domain will 301 redirect to https://acme.com with the original path and query preserved.


Redirect Only a Single URL (Optional Variant)

Sometimes you don’t want to move the whole domain—just one page.

Goal

Only redirect /old-page to https://acme.com/new-page, while leaving everything else on the site as-is.

Nginx snippet

In Additional nginx directives for that domain, use:

Notes:

  • location = /old-page matches exactly /old-page (no trailing slash, no extra path).
  • Other URLs (like /blog, /contact) will not be affected.

You can add multiple location blocks if you need multiple individual redirects.


Redirect Non-WWW to WWW on acme.com (Bonus Example)

If you host acme.com on the same Plesk server and want to redirect all http://acme.com traffic to https://www.acme.com, you can use:

This should be placed in Additional nginx directives for the acme.com vhost. (For many setups, it’s better to handle this at the DNS and vhost level, but this pattern is common and works fine for simple cases.)


How to Test Your Redirect

After saving your changes, test from your browser and from the command line.

1. Browser Test

  • Visit http://oldsite.com/ and a few inner pages (like /about).
  • Confirm you end up at the corresponding https://acme.com/... URLs.

2. Command Line Test (curl)

From a terminal:

You should see a 301 status and a Location header pointing to https://acme.com/some-path:

If you see a 200 instead of 301, or the Location header is wrong, double-check the Nginx snippet and that you edited the correct domain in Plesk.


Common Gotchas

1. Wrong domain in the wrong vhost

Make sure you’re editing Apache & nginx Settings for the domain that actually receives the traffic you want to redirect.


2. Conflicts with other custom directives

If there are existing location blocks or other return directives in Additional nginx directives, they might conflict.

For a “simple everything to acme.com” redirect, you usually want the bare return 301 ... without additional location blocks around it, so it hits all requests.


3. Mixed content / caching weirdness

  • Browsers sometimes cache redirects aggressively. Test in a private/incognito window if you’ve changed the target.
  • If you had previous redirects (e.g., via .htaccess or PHP), clear them out so Nginx is the single source of truth.

When to Use Nginx vs Apache for Redirects

On Plesk, you can also configure redirects using:

  • Hosting Settings → “Permanent SEO-safe 301 redirect” (for some simple cases)
  • Apache & nginx Settings → Additional Apache directives or .htaccess

However, Nginx is generally preferred for:

  • Global domain-to-domain redirects
  • Performance and simplicity
  • Avoiding per-request .htaccess parsing

If you’re already using Nginx as a reverse proxy (the default), Nginx-level redirects are a clean, efficient solution.


Summary

To add a domain-wide redirect to acme.com on a Plesk server with Nginx:

  1. Go to Websites & Domains → [your domain] → Apache & nginx Settings
  2. In Additional nginx directives, add:
  3. Save and test with your browser and curl.

You’ll now have a fast, server-level 301 redirect that preserves URLs and sends traffic exactly where it needs to go.

Have a project or a problem?

Talk with a senior engineer for practical recommendations—no obligation.

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.