server {
listen 80;
server_name admin.my.com; location / {
root D:/www/webroot;
index index.php;
} error_page 404 = http://admin.my.com/error.html; location ~ \.php$ {
root D:/www/webroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME D:/www/webroot$fastcgi_script_name;
include fastcgi_params;
}
}
fastcgi.conf如上配置我这个系统的url结构(非伪静态,只是在入口文件中作了转换):如:
http://admin.my.com/index.php/Index/image_code
http://admin.my.com/index.php/Admin/edit_config
http://admin.my.com/index.php/News/add
……
index.php是入口文件,单一入口但是问题来了,当我访问http://admin.my.com/index.php/Index/image_code的时候
事实上文件路径指向了:D:/www/webroot/index.php/Index/image_code/index.php
因为上面的location中配置了:index index.php; 大概url中的后缀名不是php或者html或者其他“物理存在”的文件,都会自动加上index.php吧,是么????????????我的目的就是:无论index.php后面有多少个斜杠构成的url,入口文件只能是前面的index.php,而不是把后面的参数认成目录并自动加上index.php。我知道这个url结构很不规则,但目前改起来比较费事,时间关系,所以在想有没有办法通过nginx配置来解决。求大神,求大仙,谢谢。感觉还是apache好用,一下子就搞定了:<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /
ServerName admin.my.com
Alias / "D:/www/webroot/"
<Directory "D:/www/webroot/">
Options FollowSymLinks MultiViews ExecCGI
Order allow,deny
Allow from all
</Directory>
ErrorLog logs/admin-error.log
#CustomLog logs/admin-access.log common
</VirtualHost>
nginxapacheserver
解决方案 »
- 请教PHP网址跳转问题,谢谢!
- ajax写法
- 通过odbc查询表,怎么获得查询出来的行数,急急!!
- supplied argument is not a valid MySQL 初步判定为SQL语句错误
- 用户注册后 发送 欢迎邮件的问题
- 关于一个简单的数据库操作类
- zengframwork 求教
- 那么对于生成静态页面的网站 ,要实现多语言,是不是要生成两份静态页面,一份简体,一份繁体???
- 安装freetype2.2.1 出错make: Nothing to be done for `unix',请高手指点下,在线等
- asp网站如何改写成php网站,静态部分怎么提取
- 淘宝资深架构师微博的一句话,我来问问
- php如何将接受到的字节流转为Unicode编码啊
csdn最近发帖很不好使用 编辑器要半天才加载出来
神马情况
去掉php后的 $ 正则中$意味着结束。去掉也就告诉了nginx把所有.php*文件交给fpm处理,而不只是.php。
然后将执行文件名改为index.php
fastcgi_param SCRIPT_FILENAME D:/www/webroot/index.php;
剩下的就看你的应用了。这个算是比较简单的配置,要想了解更完善的方法,自己去搜吧,这方面的说明真太多了