nginx多域名配置与 pathinfo(/ 文件夹形式) URL访问不支持配置
2016-02-24 11:31
761 查看
多域名支持(设置域名 www.ci.com)
nginx安装目录 whereis nginx 查看相关信息
1.查看nginx配置文件
/etc/nginx/nginx.conf 里面这两个是否被注释(必须开启)
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
2.在sites-enabled或者conf.d 下面新建 ci.conf(ci为域名主体部分)
3.复制 /etc/nginx/sites-available/default 里面的内容 粘贴到ci.conf里面,更改 root 路径就可以。
4.编辑 /etc/hosts 内容
添加一行 127.0.0.1 www.ci.com
5. 重启 nginx
service nginx restart或者 /etc/init.d/nginx restart (非root用户要提权才能运行成功)
6.打开你设置的域名浏览
配置nginx文件夹形式URL(pathinfo)访问支持
只须要在对应的 ci.conf (域名www.ci.com其它域名类似)中
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
添加着色部分就可以。
nginx安装目录 whereis nginx 查看相关信息
1.查看nginx配置文件
/etc/nginx/nginx.conf 里面这两个是否被注释(必须开启)
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
2.在sites-enabled或者conf.d 下面新建 ci.conf(ci为域名主体部分)
3.复制 /etc/nginx/sites-available/default 里面的内容 粘贴到ci.conf里面,更改 root 路径就可以。
4.编辑 /etc/hosts 内容
添加一行 127.0.0.1 www.ci.com
5. 重启 nginx
service nginx restart或者 /etc/init.d/nginx restart (非root用户要提权才能运行成功)
6.打开你设置的域名浏览
配置nginx文件夹形式URL(pathinfo)访问支持
只须要在对应的 ci.conf (域名www.ci.com其它域名类似)中
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
添加着色部分就可以。
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 把Lua编译进nginx步骤方法
- web 应用中常用的各种 cache详解
- Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略
- window+nginx+php环境配置 附配置搭配说明
- 解析CI即CodeIgniter框架在Nginx下的重写规则
- 将PHP从5.3.28升级到5.3.29时Nginx出现502错误
- 基于Nginx0.8.54+PHP5.3.4+MySQL5.5.8的全新LNMP稳定版架构搭建的VPS
- Nginx(PHP/fastcgi)的PATH_INFO问题