php网站路由问题 亲们,像人人二手车一样的网站,https://www.renrenche.com/xa/lingmu/ 每选中一个城市,域名后面的参数就变化,但是访问的控制器其实还是一个,https://www.renrenche.com/xianyang/lingmu/这种应该怎样弄呢? 解决方案 » 要配合web服务器的重写(rewrite) 请教一下 这个rewrite该怎样写呢 我的配置是这样的server { listen 80; server_name www.esc.com m.esc.com; root "E:/WWW/bojing"; if ($host = "www.esc.com"){ set $index index.php; } if ($host = "m.esc.com"){ set $index mobile.php; } location / { index $index; autoindex off; } rewrite ^/(.*)$ /cd$1 last; if (!-e $request_filename) { #Tekin DIy rewrite ^/(.*)$ /$index$1 last; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } } location / { index $index; autoindex off; rewrite ^([^\.]*)/(\w+)/(\w+)$ $1/$index?city=$2&car=$3 last; }改成你自己的真实url和参数名称 https://www.renrenche.com/xa/lingmu/ 变化的只是这个,并不需要修改重写规则!因为 https://www.renrenche.com/xa/lingmu/ 本身就在重写中 PHP采集利器:Snoopy 试用心得[转] Php cookie在Frameset下取不到值丢失 UChome添加MYOP应用后无法获取用户信息 小弟 有个小问题 请大侠赐教 顺便送上70分 用php插入数据只可以插入数字和字母插入不了文字 织梦(DedeCMS)的搜索页面,可以将搜索结果按照相关度排序吗? 免费图标控件都有哪些啊?highChart收费,用了个jqplot有问题,求推荐个好用的效果炫的控件 网站浏览达到100W,服务器该怎么配置 phpweb安装出现乱码 从predis读出来的键和值排序后内容不对 谁来帮忙看下这个代码谢谢 关于构造函数析造函数,大神进来瞧瞧
请教一下 这个rewrite该怎样写呢
我的配置是这样的
server {
listen 80;
server_name www.esc.com m.esc.com; root "E:/WWW/bojing";
if ($host = "www.esc.com"){
set $index index.php;
}
if ($host = "m.esc.com"){
set $index mobile.php;
}
location / {
index $index;
autoindex off;
}
rewrite ^/(.*)$ /cd$1 last;
if (!-e $request_filename) {
#Tekin DIy
rewrite ^/(.*)$ /$index$1 last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
location / {
index $index;
autoindex off;
rewrite ^([^\.]*)/(\w+)/(\w+)$ $1/$index?city=$2&car=$3 last;
}改成你自己的真实url和参数名称
变化的只是这个,并不需要修改重写规则!
因为 https://www.renrenche.com/xa/lingmu/ 本身就在重写中