您的位置:首页 > 运维架构 > Nginx

nginx 配置web 虚拟文件夹 而且codeIgniter,thinkphp 重定向url 地址

2016-04-03 20:30 716 查看
nginx 配置虚拟文件夹而且url 重定向

server {
#侦听80port
listen 8090;
#定义使用www.xx.com訪问
server_name  127.0.0.1;

#设定本虚拟主机的訪问日志
access_log  /var/log/nginx/access.log;
error_log   /var/log/nginx/error.log;
root  /home/lxy/www/cs/;         #定义服务器的默认站点根文件夹位置

#默认请求
location / {
index index.php index.html index.htm;   #定义首页索引文件的名称
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?

$1 last;
break;
}
}

#PHP 脚本请求所有转发到 FastCGI处理. 使用FastCGI默认配置.
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/lxy/www/cs/$fastcgi_script_name;
include fastcgi_params;
}

#禁止訪问 .htxxx 文件
location ~ /\.ht {
deny all;
}

}


当中 if (!-e $request_filename) {

rewrite ^/(.*)$ /index.php?$1 last;

break;

} i

就是对 url 重写。重写后的url 能够通过 http://127.0.0.1:8090/index.php/Page/index 訪问web 站点
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: