服务器 发布日期:2024/11/1 浏览次数:1
自动列出目录配置:
下载过开源软件的都知道,一个很简单的页面列出了所有版本的源码包,这就是开启了自动列出目录
如下配置,在虚拟主机location / {……}目录控制中配置自动列出目录:
location / { autoindex on; }
浏览器本地缓存设置:
浏览器是为了加速浏览,浏览器在用户磁盘上对最近请求过的文件进行存储,当访问者再次请求这个页面,
浏览器可以从本地磁盘显示文件,以达到加速浏览的效果,节约了网络资源,提高了网络效率
关键字: expires
默认值: off
作用域: http,server.location
用途: 通过expires指令控制http应答中的”Expires”和”Cache-Control”的头信息
配置项:
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)"htmlcode">server { listen 80 default; server_name www.wpython.com; index index.html index.htm index.php; root /alidata/www/www.wpython.com; # wordpress 伪静态规则 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; } } rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } access_log /alidata/log/nginx/access/www.wpython.com.log; } server { listen 80 default; server_name www.pyyw.net; index index.html index.htm index.php; root /alidata/www/www.pyyw.net; # wordpress 伪静态规则 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; } } rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } access_log /alidata/log/nginx/access/www.pyyw.net.log; }