• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Nginx for Newbie: setting up absolute_redirect directive

December 18, 2023

Nginx for Newbie: Setting up the absolute_redirect Directive

Nginx is a popular web server and reverse proxy server that is known for its high performance, scalability, and flexibility. It is widely used by web developers and hosting providers to serve websites and applications efficiently. One of the many features of Nginx is the ability to configure various directives to customize its behavior. In this article, we will explore the absolute_redirect directive and how to set it up in Nginx.

Understanding the absolute_redirect Directive

The absolute_redirect directive in Nginx allows you to control whether redirects issued by the server should be absolute or relative. By default, Nginx uses relative redirects, which means that the redirect URL is relative to the requested URL. However, in some cases, you may want to use absolute redirects, where the redirect URL includes the scheme and hostname.

Using absolute redirects can be useful in scenarios where you have multiple server blocks or when you want to redirect users to a different domain or subdomain. It ensures that the redirect works correctly regardless of the requested URL.

Setting up the absolute_redirect Directive

To set up the absolute_redirect directive in Nginx, you need to modify your server block configuration. The server block is where you define the settings for a specific website or application. Here’s an example of how to enable absolute redirects:

server {
    listen 80;
    server_name example.com;
    absolute_redirect on;
    ...
}

In the above configuration, we have added the absolute_redirect directive and set it to “on” to enable absolute redirects. You can also set it to “off” to use relative redirects.

After making the changes, save the configuration file and restart Nginx for the changes to take effect. You can do this by running the following command:

sudo systemctl restart nginx

Testing the absolute_redirect Directive

Once you have enabled the absolute_redirect directive, you can test it by issuing a redirect from your website or application. You can use tools like cURL or web browsers to check the redirect URL.

For example, if you have a redirect configured in your application code or using Nginx’s rewrite rules, you can check the redirect URL to see if it is absolute or relative.

Summary

The absolute_redirect directive in Nginx allows you to control whether redirects issued by the server should be absolute or relative. By default, Nginx uses relative redirects, but you can enable absolute redirects by adding the absolute_redirect directive to your server block configuration.

If you are looking for a reliable VPS hosting provider to host your website or application, consider Server.HK. With their top-notch VPS solutions, you can ensure high performance and scalability for your online presence.

Recent Posts

  • How to Migrate Your Website to a Hong Kong VPS: Zero-Downtime Transfer Guide (2026)
  • How to Set Up Redis on Hong Kong VPS: Caching, Queues, and Session Storage (2026)
  • How to Host a Python Flask or Django Application on Hong Kong VPS (2026)
  • How to Set Up WireGuard VPN on a Hong Kong VPS: Step-by-Step Guide 2026
  • Hong Kong VPS vs DigitalOcean: Cost, Performance, and China Routing Compared (2026)

Recent Comments

  1. vibramycin injection on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  2. allopurinol for gout on CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  3. antibiotics online purchase on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)
  4. linezolid cost oral on Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  5. metoprolol generic on Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot