Home >Backend Development >PHP Tutorial >Domain name jumps from www to non-www, two solutions: Apache and Nginx
Background: www jumps to non-www.
http://www.jiutianniao.com and http://jiutianniao.com can be accessed.
However, if you want to redirect www to non-www, it is easier to enter and let search engines treat them as the same website.
2 solutions:
1.Apache:
Create a new ".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 }
Reference: http://langui.me/2010/11/apache-www-to-non-www/
----- ---------------------------------------------------- ----------------------
Wuhan Jiutianniao-p2p online loan system development-Internet application software development
Company official website: http://jiutianniao.com
Social Q&A: http://ask.jiutianniao.comThe above introduces two solutions for domain name jump from www to non-www, Apache and Nginx, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.