1、nginx二级域名配置wap首页
你在你的if里添加一个location试试?
2、Nginx如何配置主域名重定向到www二级域名
server {
listen 80;
server_name yunfinal.com;
return http://www.yunfinal.com;
}
如果希望让copy客户端永远记住这个重定向那就增加301配置
return 301 http://www.yunfinal.com;
3、nginx https怎么配置二级域名问题
请参考代码,https如果监听的是443端口,则网址后面不需要加端口;如果监听的不是443端口则需要加端口。如下图的 https://*.9yyule.com:8888
#user nobody;
worker_processes 4;
error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
# server_names_hash_bucket_size 128K;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_body_buffer_size 8m;
server_tokens off;
ignore_invalid_headers on;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
proxy_temp_path /usr/local/nginx-1.8/proxy_temp;
proxy_cache_path /usr/local/nginx-1.8/proxy_cache levels=1:2 keys_zone=cache_one:100m inactive=2d max_size=10g;
gzip on;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
server {
listen 80 default;
return 500;
server_tokens off;
root html; }
#server {
# listen 443 default;
# return 500;
# server_tokens off;
# root html; }
upstream name {
# server 116.31.118.114:8098 weight=2 fail_timeout=3s backup;
server 114.55.32.244:888 weight=1 max_fails=3 fail_timeout=300;
server 114.55.85.154:8080 weight=1 max_fails=3 fail_timeout=300;
ip_hash;
}
server {
listen 8888 default ;
server_name *.9yyule.com *.jiuyiyule.com *.yinqicai.com;
server_tokens off;
ssl on;
ssl_certificate /usr/local/nginx/conf/web.crt;
ssl_certificate_key /usr/local/nginx/conf/web.key;
error_page 497 https://$host:$server_port$request_uri;
location ~*/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://name;
proxy_http_version 1.1;
proxy_set_header Accept-Encoding "";
location ~ .*.(gif|jpg|png|html|css|js|ico|swf|pdf)(.*) {
proxy_pass http://name;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cache_one;
add_header Nginx-Cache $upstream_cache_status;
proxy_cache_valid 200 304 301 302 24h;
proxy_cache_valid 404 1m;
proxy_cache_valid any 2d;
proxy_cache_key $host$uri$is_args$args;
expires 7d;
}
}
location ~ /purge(/.*)
{
auth_basic "TDT Center CACHE Center";
auth_basic_user_file /tmp/htpasswd;
allow 127.0.0.1;
deny all;
proxy_cache_purge cache_one $host$1$is_args$args;
}
# error_page 404 /404.html;
# error_page 400 501 502 503 504 https://$host:$server_port$request_uri;
# location = /50x.html {
# root html;
# }
# redirect server error pages to the static page /50x.html
#
# error_page 500 502 503 504 /50x.html;
}
}
4、建站主机如何配置Nginx,实现二级域名
建议你安装一个宝塔面板,完全图形化操作,绑定二级域名非常简单。
5、nginx如何绑定二级域名
nginx绑定二级域名是通过编辑配置文件中的server 的server_name来处理的。
如:
server {
listen 8001;
server_name domain_name;
#charset koi8-r;
#access_log logs/access.log main;
location / {
root html;
index index.html index.htm;
}
}
6、nginx 怎么实现二级域名跳转到指定 URL
server {
listen 80;
server_name 二级域名;
location / {
rewrite ^/(.*)$ 重定向的域名$1 permanent;
}
}
```
7、nginx怎么把二级域名绑定子目录
RewriteCond %{HTTP_HOST} ^(bbs|blog|download).domain.com$
RewriteRule ^(.*)$ /%1/$1 [L, NC]
这样,会自动把bbs对应到bbs目录,blog对应到blog目录,download对应到download,要加新的域名时,只需要在上面那行按格式添加即可
8、Nginx如何配置二级域名
和顶级域名一样的设置。只是把servername 改成你的二级域名就可以了
9、怎么把nginx子目录301重定向到网站二级域名
比如phpwindow.com/download/ 301跳转到download.phpwindow.com
用的lnmp,我是直接加的一个download.conf文件放到/usr/local/nginx/vhost
然后在phpwindow.com的conf配置里面加一条include download.conf;
重启完毕。
download.conf的内容为:
location ~* ^/bbs/ {
rewrite ^/download/(.*)$ http://download.phpwindow.com/$1 permanent;
}
不添加这个conf应该也可以,直接写到nginx.conf文件里就可以了。
之后重启nginx—service nginx reload,访问看看效果吧!!