我需要重定向几个网址。 301永久
http://example.com/downloads/example.exe至http://example.com/emaple-page/
我需要为3个URL执行此操作,我将在.conf文件
上执行此操作 server {
listen 80;
server_name http://example.com/downloads/example.exe;
rewrite ^/(.*) http://example.com/emaple-page/$1 permanent;
}
server {
listen 80;
server_name http://example.com/downloads/example2.exe;
rewrite ^/(.*) http://example.com/emaple-page/$1 permanent;
}
server {
listen 80;
server_name http://example.com/downloads/example3.exe;
rewrite ^/(.*) http://example.com/emaple-page/$1 permanent;
}
我想知道这是对的吗?最好的方法是什么?
答案 0 :(得分:0)
每个域只能包含1个server
部分。您可以将原始网址直接放在rewrite
子句中。
server {
listen 80;
server_name example.com;
index index.html index.php
rewrite ^/downloads/example\.exe http://example.com/emaple-page/ permanent;
rewrite ^/downloads/example2\.exe http://example.com/emaple-page2/ permanent;
rewrite ^/downloads/example3\.exe http://example.com/emaple-page3/ permanent;
}