我使用 nginx 作为我的网络服务器,并在 Facebook 上发布了一些链接。我刚刚将我的链接从示例.com到example.com/en/。因此,Facebook 上的所有链接都将无法使用,我希望重定向所有示例.com链接到example.com/en。
我的配置:
server {
listen 80;
server_name example.com;
charset utf-8;
access_log logs/xxxxxx.access.log;
root /var/www/html;
index index.php;
location = / { return 301 /cn/; }
location / {
try_files $uri $uri/ /cn/index.php?q=$uri;
}
location /en {
try_files $uri $uri/ /en/index.php?q=$uri;
}
location /my {
try_files $uri $uri/ /my/index.php?q=$uri;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}