Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure web page 301 redirection in Nginx

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to configure web page 301redirection in Nginx". In daily operation, I believe that many people have doubts about how to configure web page 301redirect in Nginx. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to configure web page 301redirection in Nginx". Next, please follow the editor to study!

My profile is

Server

{

Listen 80

Server_name xxx.net www.xxx.net

Index index.html index.htm index.php default.html default.htm default.php

Root/ home/wwwroot/xxx.net/videodownload/videodownproject

Include rewrite/xxx.conf

Include enable-php-pathinfo.conf

Location ~. *\. (gif | jpg | jpeg | png | bmp | swf) $

{

Expires 30d

}

Location. *\. (js | css)? $

{

Expires 12h

}

Location ~ / .well-known {

Allow all

}

Location ~ /\.

{

Deny all

}

# not www automatically redirects to www

If ($host! = 'www.xxx.net') {

Rewrite ^ / (. *) $https://www.xxx.net/$1 permanent

}

# not https automatically jumps to https (I was unable to get http by other methods)

If ($http_x_forwarded_proto! = "https")

{

Rewrite ^ / (. *) $https://$host/$1 permanent

}

Access_log / home/wwwlogs/xx.log

}

Server {

Listen 443

Server_name www.xxx.net

Index index.html index.htm index.php default.html default.htm default.php

Root/ home/wwwroot/xxx.net/videodownload/videodownproject

Ssl on

Ssl_certificate / usr/local/nginx/cert/cloudflare/xxx.net.pem

Ssl_certificate_key / usr/local/nginx/cert/cloudflare/xxx.net.key

Include rewrite/xxx.conf

Include enable-php-pathinfo.conf

Location ~. *\. (gif | jpg | jpeg | png | bmp | swf) $

{

Expires 30d

}

Location. *\. (js | css)? $

{

Expires 12h

}

Location ~ / .well-known {

Allow all

}

Location ~ /\.

{

Deny all

}

Access_log / home/wwwlogs/xxx.log

}

At this point, the study on "how to configure web page 301 redirection in Nginx" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report