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 http://www.jiutianniao.com and http://jiutianniao.com 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} ^ www.jiutianniao.com

RewriteRule (. *) http://jiutianniao.com/#1 [R = 301, L]

2. Nginx:

Server {

37 server_name www.fansunion.cn;

38 return 301 $ scheme: // fansunion.cn $ request_uri;

39}

40 server {

41 listen 80;

42 server_name fansunion.cn;

43

49 charset UTF-8;

50 access_log off;

51

52 ssi on;

53 ssi_silent_errors on;

54

55 location /{

56 proxy_pass http: // localhost: 8888;

57}

58

59}

References: http://langui.me/2010/11/apache-www-to-non-www/
------------------------------------------------------------------------

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

Official website: http://jiutianniao.com

Social Q & A: http://ask.jiutianniao.com

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: info-contact@alibabacloud.com 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.