Home > Backend Development > PHP Tutorial > Detailed explanation of using Nginx to implement 301 redirection

Detailed explanation of using Nginx to implement 301 redirection

WBOY
Release: 2016-07-29 08:59:13
Original
1186 people have browsed it

只需配置如下:

    server {
        listen       80;
        server_name  localhost;
	server_name_in_redirect off;
	proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	if ($host = 'www.xxx.com' ) {
	    rewrite ^/(.*)$ http://xxx.com/$1 permanent;
        }
	location / {
	    proxy_pass http://127.0.0.1:8080/;
        }
    }
Copy after login

以上就介绍了使用Nginx实现301重定向详解,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template