Resolution for domain name jump from www to non-www, Apache and Nginx2

Source: Internet
Author: User
: This article describes how to redirect a domain name from www to non-www, Apache, and Nginx2. For more information about PHP tutorials, see. Background: jump from www to non-www.

Both and are accessible.

However, if you want to redirect www to a non-www website, the input is simpler so that search engines can treat them as the same website.

Two solutions:

1. Apache:

Create a ". htaccess" file under the project jiutianniao.

RewriteEngine On

RewriteCond % {HTTP_HOST} ^

RewriteRule (. *) [R = 301, L]

2. Nginx:

Server {

37 server_name;

38 return 301 $ scheme: // $ request_uri;


40 server {

41 listen 80;

42 server_name;


49 charset UTF-8;

50 access_log off;


52 ssi on;

53 ssi_silent_errors on;


55 location /{

56 proxy_pass http: // localhost: 8888;





Wuhan Jiutian bird-p2p online loan system development-Internet application software development

Official website:

Social Q & A:

The above describes how to redirect a domain name from www to a non-www, Apache, and Nginx2 solution, including some content, and hope to help friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.