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

Explain in detail the method of jumping to a domain name with www in nginx 301

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Prerequisites: Add domain.com and www.domain.com to DNS to point to your host IP address

methods 1. Open the nginx.conf file to find your server configuration segment:

server { listen 80; server_name www.domain.com domain.com; if ($host != 'www.domain.com' ) { rewrite ^/(.*)$ http://www.domain.com/$1 permanent ;}

Method 2. Write two servers in the configuration file, domain.com points to www.domain.com

server { listen 80; server_name www.domain.com;}server { server_name domain.com; rewrite ^(.*) http://www.domain.com/$1 permanent;}

Additional:

301 & 302 Jump Difference

301 Permanent jump: When a user or search engine sends a browsing request to a website server, a status code in the header information returned by the server indicates that the page is permanently transferred to another address.

302 temporary jump, is also a status code, meaning temporarily turned to another URL.

The main difference between the two is that 302 is easily regarded as spam by search engines, while 301 is not.

The above is all the content of this article, I hope to help everyone's study, but also hope that everyone a lot of support.

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

Servers

Wechat

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

12
Report