nginx内容页nginx 重定向到文件二级域名

& nginx泛域名解析实现二级域名多域名
nginx泛域名解析实现二级域名多域名
利用nginx泛域名解析配置二级域名和多域名
网站的目录结构为
├── bbs
└── www
html为nginx的安装目录下默认的存放源代码的路径。
bbs为论坛程序源代码路径
www为主页程序源代码路径
把相应程序放入上面的路径通过
http://www.youdomain.com 访问的就是主页
http://bbs.yourdomain.com 访问的就是论坛
其它二级域名类推。
server_name
~^(?&subdomain&.+).yourdomain.com$;
index.html index.htm index.
fastcgi_intercept_
error_page
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't
# break when using query string
try_files $uri $uri/ =404;
# redirect server error pages to the static page /50x.html
error_page
500 502 503 504
location = /50x.html {
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
fastcgi_pass
127.0.0.1:9000;
fastcgi_index
fastcgi_param
SCRIPT_FILENAME
$document_root$fastcgi_script_
fastcgi_param
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /.ht {
1234567891011121314151617181920212223242526272829303132333435363738
server {&&&&&&&&listen&&&&&& 80;&&&&&&&&server_name&&~^(?&subdomain&.+).yourdomain.com$;&&&&&&&&root&& html/$subdomain; &&&&&&&&index&&index.html index.htm index.php;&&&&&&&&fastcgi_intercept_errors on;&&&&&&&&error_page&&404&&&&&&= /404.html;&&&&&&&&location / {&&&&&&&&&&&&&&&&# This is cool because no php is touched for static content.&&&&&&&&&&&&&&&&# include the "?$args" part so non-default permalinks doesn't&&&&&&&&&&&&&&&&# break when using query string&&&&&&&&&&&&&&&&try_files $uri $uri/ =404;&&&&&& }&&&&&&&&&# redirect server error pages to the static page /50x.html&&&&&&&&#&&&&&&&&error_page&& 500 502 503 504&&/50x.html;&&&&&&&&location = /50x.html {&&&&&&&&&&&&root&& html;&&&&&&&&}&&&&&&&&&# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&&&&&&&&#&&&&&&&&location ~ .php$ {&&&&&&&&&&&&fastcgi_pass&& 127.0.0.1:9000;&&&&&&&&&&&&fastcgi_index&&index.php;&&&&&&&&&&&&fastcgi_param&&SCRIPT_FILENAME&&$document_root$fastcgi_script_name;&&&&&&&&&&&&fastcgi_param&&domain $subdomain;&&&&&&&&&&&&include&&&&&&&&fastcgi_params;&&&&&&&&}&&&&&&&&&# deny access to .htaccess files, if Apache's document root&&&&&&&&# concurs with nginx's one&&&&&&&&#&&&&&&&&location ~ /.ht {&&&&&&&&&&&&deny&&all;&&&&&&&&}&&&&}
总结一下步骤就是
1.把上面的红色配置换成你的域名后添加到你的nginx.conf配置文件
2.确认要增加的二级域名,如bbs.yourdomain.com
3.设置bbs.yourdomain.com解析到你的nginx服务器ip
4.在html目录下创建bbs目录
5.把源码放入bbs目录
6.重新加载nginx配置
kill -HUP cat /usr/local/lnmp/nginx/nginx.conf
(需要把上面命令的路径换成你的配置文件路径)
7.访问http://bbs.yourdomain.com
除非注明,本站文章均为: 原创,转载请注明本文地址:
- 631,157 views - 418,561 views - 378,480 views - 244,963 views - 212,388 views - 207,335 views - 165,235 views - 159,645 views - 148,896 views - 133,002 views本准备换Linux服务器,所以数据迁移暂时需要使用静态页面临时代替一下,之前的article.asp?id=xxx都要重定向到静态文件article/xxx.htm,下面看看Nginx是如何进行Rew...
背景前几天写了个Jekyll Theme, 想在Coding开一个链接进行展示但是遇到了不小的麻烦。首先我使用的是Coding, 理论上和Github没太大区别。Github的相同问题可以参考这篇文章...
在项目中做form表单功能提交时,防止用户客户端后退或者刷新时重复提交问题,需要在服务端进行重定向跳转,具体跳转方式有以下几种方式:
@Reques...
读取请求参数值
方式一 通过request对象
方式二 通过 @RequestParam注解
方式三 封装成javabean
step1. 写一个java类,要求见图示:
12.7-12.14 nginx默认虚拟主机,用户认证,域名重定向,日志,,静态文件不记录日志,防盗链,访问控制
默认虚拟主机nginx默认虚拟主机的概念和apache类似,当域名定向到本主机时,如果...
有些代码被注释了,是因为本机调试时,对其他代码有影响
1.重定向的/指的是127.0.0.1,
如果不加,那么则从akazamtest01加上指定的页面名
不能两个response....
nginx rewrite 详解
参数含义 示例展示
http://homeway.me
0x01.About之前写过Nginx重定向了,http://homeway.me//nginx-reverse-proxy-conf/,但当时...
rewrite指令的最后一项参数为flag标记,支持flag标记有:
相当于apache里面的[L]标记,表示rewrite。
2.break本条规则匹配完...
他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)微信公众号:centoscn
nginx 配置子域名的重定向
目前很多网站可以为用户分配一个自己定义的二级域名,例如:myname.netingcn.com,但实际访问的地址可能为www.netingcn.com/user.php?uid=myname。要使其能正常工作,首先在DSN解析那里需要配置泛域名解析,接下来在nginx配置文件中设置rewrtie即可。nginx配置如下:server {
server_name *.netingcn.
if ($host ~* ^(......)\.netingcn\.com) {
set $sub_name $1;
rewrite ^/ /user.php?uid=$sub_
...这里假设所有的6个字符的子域名都是用户自定义域名,然后对其进行rewrite。另外可以通过set指令把表达式中的某些信息存放在一个变量中,而后可以使用它。
------分隔线----------------------------正文 nginx做二级域名泛解析并使一级域名301重定向到www开头的二级域名
nginx做二级域名泛解析并使一级域名301重定向到www开头的二级域名
发布时间: & 编辑:www.jquerycn.cn
jquery中文网为您提供nginx做二级域名泛解析并使一级域名301重定向到www开头的二级域名等资源,欢迎您收藏本站,我们将为您提供最新的nginx做二级域名泛解析并使一级域名301重定向到www开头的二级域名资源

我要回帖

更多关于 nginx 重定向到百度 的文章

 

随机推荐