最近需要做一个站,根目录是别的cms,二级的话是wordpress,那么就需要伪静态了,找了三种办法,分享给大家!
第一种伪静态:
location / {rewrite ^/目录名/wp-admin$ /目录名/wp-admin/ permanent; 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; }}
第二种伪静态:
location /目录名/{ rewrite ^/wp-admin$ /wp-admin/ permanent; 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; } }
第三种伪静态:
location /目录名/ { try_files $uri $uri/ /目录名/index.php?q=$uri&$args; }
保存固定链接后,弄好伪静态后要注意会不会404!!
这二级目录下安装Wordpress的伪静态三个方法就在这上面啦!