Arlicle在nginx下的配置如下:
方法一: 自己的服务器
如果服务器是你自己的,你可以操作nginx的配置文件,可以按照如下配置:
注:配置此操作后,服务的网址模式需要修改为.htaccess模式,也就是访问没有index.php在网址中间了. 配置文件中只需要SCRIPT_FILENAME变量就可以了,PATH_INFO不需要增加。
location / {
if (!-f $request_filename){
rewrite ^/(.+)$ /index.php?kohana_uri=$1 last;
}
}
location ~ .php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
方法二:租用的虚拟空间
如果你是自己租用的虚拟空间,那么只需要在开启htaccess的情况下, 修改网站根目录的.haccess文件,将里面的内容清空,然后从重写nginx的规则. 如下:
注: 只需要有SCRIPT_FILENAME的值就可以了, 不需要开启PATH_INFO的值.
location / {
if (!-f $request_filename){
rewrite ^/(.+)$ /index.php?kohana_uri=$1 last;
}
}