关于NGINX 和 CI 头疼的问题,寻求解决
本帖最后由 cxzlr 于 2012-4-10 09:56 编辑头疼的需求 知识点应该属于NGINXurl 重写的范畴
1.泛域名解析
2.除aqp.test.com ,www.test.com ,test.com,beta.test.com 外 全部 解析到某一个地址
3.去除index.php
现请高手们讨论下如何解决,知识点应该属于NGINXurl 重写的范畴
当为域名 aqp.test.com ,www.test.com ,test.com,beta.test.com正常访问
其它域名 如 33.test.com内部访问的是 www.test.com/index.php/web/index 网址栏中看到的以然是 33.test.com
44.test.com内部访问的是 www.test.com/index.php/web/index 网址栏中看到的以然是 44.test.com
如果访问 www.test.com/index.php/web/index/news/23
如何实现以上功能
目前的NGINX配置如下
server {
listen 80;
server_name beta.test.com test.com www.test.com
set $wwwroot /usr/share/nginx/html;
location / {
root $wwwroot;
index index.html index.htm index.php;
rewrite ^/$ /index.php last;
rewrite ^/(?!index\.php|robots\.txt|bbs|public)(.*)$ /index.php/$1 last;
}
error_page 500 502 503 504/50x.html;
location = /50x.html {
root $wwwroot;
}
location~^(.+\.php)(.*)$ {
root $wwwroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
}
location ~* ^.+\.(jpg|jpeg|gif|png|bmp)$ {
access_log off;
root $wwwroot;
expires 30d;
break;
}
location ~ /\.ht {
denyall;
}
}
寻求高手解决 nginx我也没配置好 所以后台干脆直接用了apache做PHP处理 这样pathinfo就很容易解决了 哪个高手给处理下。 本帖最后由 暗夜星辰 于 2012-4-9 20:38 编辑
if ($host != ‘www.test.com’ ) {
rewrite ^/(.+)$ /index.php last;
}
放~~~~~来了 继续寻找高手结决呀。 暗夜星辰 发表于 2012-4-9 20:37 static/image/common/back.gif
if ($host != ‘www.test.com’ ) {
rewrite ^/(.+)$ /index.php last;
}
我想 重写到
www.test.com/index.php/web/index
下面 本帖最后由 暗夜星辰 于 2012-4-10 00:51 编辑
关键词:nginx 反向代理
关键代码:
server
{
listen 80;
server_name 33.test.com;
location / {
proxy_pass www.test.com/index.php/web/index;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
简单解释:将 www.test.com/index.php/web/index反向 映射到 33.test.com 的根目录
反向代理,方法不错。
页:
[1]
2