[英]nginx 301 permanent redirect Urls to page/Folder
i need to redirect few URLs. 我需要重定向几个URL。 301 permanent
301永久
http://example.com/downloads/example.exe to http://example.com/emaple-page/ http://example.com/downloads/example.exe到http://example.com/emaple-page/
i need to do this for 3 URLS , i'm going to do this on .conf file 我需要为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;
}
i want to know is this correct ? 我想知道这是正确的吗? what is the best way to do it ?
最好的方法是什么?
You can have only 1 server
section for each domain. 每个域只能有一个
server
部分。 You can put the original URL directly in the rewrite
clause. 您可以将原始URL直接放在
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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.