全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2176|回复: 8
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
1#
发表于 2011-4-22 22:30:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
就是有时网址的/后面直接有?,那我想让nginx解析index.php动态文件,如果没有?就直接解析此目录下的html文件,这样要怎么写nginx呢?
2#
发表于 2011-4-22 22:35:02 | 只看该作者
不是很明白楼主描述的问题。
3#
发表于 2011-4-22 22:37:56 | 只看该作者
描述的不太清楚啊
4#
 楼主| 发表于 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
5#
 楼主| 发表于 2011-4-22 22:49:30 | 只看该作者
有没有知道这个功能nginx要怎么写呢
6#
 楼主| 发表于 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;
        }

我这样写,网站都打不开了
7#
发表于 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;
        }
8#
发表于 2011-4-22 23:13:42 | 只看该作者
用location/套一下试试。
9#
 楼主| 发表于 2011-4-22 23:36:13 | 只看该作者
if ($request_uri ~* "/\?(.*)$")
                        {
                rewrite  ^/?(.*)$  /index.php?$1 permanent;
                        }

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

本版积分规则

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

GMT+8, 2024-5-3 18:10 , Processed in 0.079987 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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