网友回复
在 Nginx 中设置域名跳转可以通过配置服务器块(server block)来实现。以下是基本的步骤和示例配置:
1. 创建 Nginx 配置文件通常,Nginx 的配置文件位于 /etc/nginx/nginx.conf 或 /etc/nginx/conf.d/ 目录中。你可以在这些地方找到现有的配置文件或创建一个新的配置文件。
sudo nano /etc/nginx/conf.d/example.conf2. 编辑 Nginx 配置文件
在配置文件中添加服务器块(server block)来设置域名跳转。
假设你要将 example.com 跳转到 www.example.com,配置如下:
server { listen 80; server_name example.com; return 301 $scheme://www.example.com...
点击查看剩余70%