本人服务器用的是lnmp环境
空间配置文件
server
{
listen 80;
#listen [::]:80;
server_name json.all-tv.com.cn;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/json.all-tv.com.cn;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
include json.conf;
access_log /home/wwwlogs/json.all-tv.com.cn.log access;
}
加入的json.conf
location / {
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite /!.(gif|jpg|png|css|js|html|ico|zip|rar|pdf|xml|mp4|mpg|flv|swf|mkv|ogg|avi|woff|svg|eot|ttf|jar)$ /index.php last;
}
}
首页是可以的但是,跳转其他页面都会显示错误
空间配置文件
server
{
listen 80;
#listen [::]:80;
server_name json.all-tv.com.cn;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/json.all-tv.com.cn;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
include json.conf;
access_log /home/wwwlogs/json.all-tv.com.cn.log access;
}
加入的json.conf
location / {
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite /!.(gif|jpg|png|css|js|html|ico|zip|rar|pdf|xml|mp4|mpg|flv|swf|mkv|ogg|avi|woff|svg|eot|ttf|jar)$ /index.php last;
}
}
首页是可以的但是,跳转其他页面都会显示错误