Redirects are vital for managing traffic on your VPS-hosted website, ensuring users reach the right URLs while boosting SEO and security. This guide simplifies configuring Nginx redirects for permanent (301), temporary (302), HTTP-to-HTTPS, www/non-www, and path-specific cases. With practical examples and tips, you’ll master Nginx redirects efficiently.
A VPS with Nginx installed
Root or sudo access
Your site’s config file (typically in /etc/nginx/sites-available/ or /etc/nginx/conf.d/)
Use this when a URL or domain has changed permanently.
🔐 Tip: Always redirect to HTTPS when possible.
Use this for temporary redirection (e.g., during maintenance).