下面是我的nginx配置文件,把伪静态代码放进去后,重新加载和重启nginx,网站的伪静态还是未生效,不知道哪里出问题了!麻烦网友帮我看看,谢谢!
user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 888;
server_name www.bt.cn;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
#error_page 404 /404.html;
include enable-php.conf;
location /{
rewrite ^app/list_(d+)_(d+).html$ /index.php?tpl=list_app&cid=$1&p=$2 break;
rewrite ^app/list_(d+).html$ /index.php?tpl=list_app&cid=$1&p=1 break;
rewrite ^app/(w+?)/(d+).html$ /index.php?tpl=list_app&cpy=$1&p=$2 break;
rewrite ^app/(w+?)/$ /index.php?tpl=list_app&cpy=$1&p=1 break;
rewrite ^sepcial/list_(d+).html$ /index.php?tpl=special_list&p=$1 break;
rewrite ^sepcial/$ /index.php?tpl=special_list&p=1 break;
rewrite ^special/(d+).html$ /index.php?tpl=special_content&id=$1 break;
rewrite ^info/list_(d+)_(d+).html$ /index.php?tpl=list_info&cid=$1&p=$2 break;
rewrite ^info/list_(d+).html$ /index.php?tpl=list_info&cid=$1&p=1 break;
rewrite ^info/(w+?)/(d+).html$ /index.php?tpl=list_info&cpy=$1&p=$2 break;
rewrite ^info/(w+?)/$ /index.php?tpl=list_info&cpy=$1&p=1 break;
rewrite ^info/(d+).html$ /index.php?tpl=content_info&id=$1 break;
rewrite ^app/(d+).html$ /index.php?tpl=content_app&id=$1 break;
rewrite ^app/(d+)_(d+).html$ /index.php?tpl=content_app_history&id=$1&hid=$2 break;
rewrite ^lastupdate/(d+).html$ /index.php?tpl=lastupdate&p=$1 break;
rewrite ^lastupdate/$ /index.php?tpl=lastupdate&p=1 break;
rewrite ^image/(.*).(w+)$ /pic.php?url=$1&type=$2 break;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /www/wwwlogs/access.log;
}
include /www/server/panel/vhost/nginx/*.conf;
}
试试这个
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
例如 wordpress 博客系统,nginx 只要设置
location / {
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}
即可实现伪静态
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。