全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2174|回复: 8

[nginx] 网址的/后面有时有?,我想让动太php文件解析,没有?就

[复制链接]
发表于 2011-4-22 22:30:26 | 显示全部楼层 |阅读模式
就是有时网址的/后面直接有?,那我想让nginx解析index.php动态文件,如果没有?就直接解析此目录下的html文件,这样要怎么写nginx呢?
发表于 2011-4-22 22:35:02 | 显示全部楼层
不是很明白楼主描述的问题。
发表于 2011-4-22 22:37:56 | 显示全部楼层
描述的不太清楚啊
 楼主| 发表于 2011-4-22 22:41:09 | 显示全部楼层
举个例子
www.abc.com/    让他解析  www.abc.com/index.html

www.abc.com/?i=123     让他解析  www.abc.com/index.php?i=123
 楼主| 发表于 2011-4-22 22:49:30 | 显示全部楼层
有没有知道这个功能nginx要怎么写呢
 楼主| 发表于 2011-4-22 22:55:42 | 显示全部楼层
server
        {
                listen       80;
                server_name www.abc.com;
                index index.html index.htm index.php;
                root  /home/www/abc;
               
                        rewrite ^/?(.*)$ /index.php?$1 permanent;
                       
        include location.conf;
                error_page 404  /404.html;
        }

我这样写,网站都打不开了
发表于 2011-4-22 23:13:28 | 显示全部楼层
server
        {
                listen       80;
                server_name www.abc.com;
                index index.html index.htm index.php;
                root  /home/www/abc;
          location / {     
                        rewrite ^/?(.*)$ /index.php?$1 permanent; }
                       
        include location.conf;
                error_page 404  /404.html;
        }
发表于 2011-4-22 23:13:42 | 显示全部楼层
用location/套一下试试。
 楼主| 发表于 2011-4-22 23:36:13 | 显示全部楼层
if ($request_uri ~* "/\?(.*)$")
                        {
                rewrite  ^/?(.*)$  /index.php?$1 permanent;
                        }

我自己试着这样写了,好像可以了,还没有发现问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-3 07:55 , Processed in 0.059334 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表