174 {
175 listen 80;
176 server_name s.tongxinmao.com;
177 index index.htm index.html index2.php;
178 root /home/wwwroot/default/txm2;
179
180
181 location / {
182 index index.htm index.html index2.php;
183 try_files $uri /index2.php$uri;
184 }
185 location ~ .+\.php($|/) {
186 fastcgi_pass unix:/dev/shm/php-cgi.sock;
187 fastcgi_index indexx2.php;
188 include fastcgi.conf;
189 fastcgi_split_path_info ^(.+\.php)(/.*)$;
190 fastcgi_param PATH_INFO $fastcgi_path_info;
191 }
192
193 }
PHP中PATHINFO处理://默认控制器及方法 及参数$_GET转存
function parseUrl(){
if (isset($_SERVER['PATH_INFO'])){
//获取 pathinfo
$pathinfo = explode('/', trim($_SERVER['PATH_INFO'], "/"));
// 获取 control
$_GET['c'] = (!empty($pathinfo[0]) ? $pathinfo[0] : 'Index');
$this->c =$_GET['c'];
array_shift($pathinfo); //将数组开头的单元移出数组
// 获取 action
$_GET['a'] = (!empty($pathinfo[0]) ? $pathinfo[0] : 'Index');
$this->a =$_GET['a'];
array_shift($pathinfo); //再将将数组开头的单元移出数组
for($i=0; $i<count($pathinfo); $i+=2){
$_GET[$pathinfo[$i]]=$pathinfo[$i+1];
}
}else{
$_GET["c"]= (!empty($_GET['c']) ? $_GET['c']: 'Index'); //默认是index模块
$_GET["a"]= (!empty($_GET['a']) ? $_GET['a'] : 'Index'); //默认是index动作
if($_SERVER["QUERY_STRING"]){
$m=$_GET["c"];
unset($_GET["c"]); //去除数组中的m
$a=$_GET["a"];
unset($_GET["a"]); //去除数组中的a
$query=http_build_query($_GET); //形成0=foo&1=bar&2=baz&3=boom&cow=milk格式
//组成新的URL
$url=$_SERVER["SCRIPT_NAME"]."/{$m}/{$a}/".str_replace(array("&","="), "/", $query);
header("Location:".$url);
}
}
}