修的了电脑 敲得了代码
     写得了前端 稳得住后端

nginx服务器上wordpress的rewrite通用配置

  1. 先编辑该vhost的配置文件

    nginx服务器上wordpress的rewrite通用配置
  2. 然后在如图所示的位置添加如下内容(如图)

    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;         }

    nginx服务器上wordpress的rewrite通用配置
  3. 然后重启nginx

    nginx服务器上wordpress的rewrite通用配置
  4. 后台选择系统提供的伪静态规则,或者自己规定一个把,比如/%post_id%.html

    然后再访问地址,发现ok啦,大功告成!

    nginx服务器上wordpress的rewrite通用配置

 

这是我的nginx配置

server {
listen 80;
server_name www.6iit.com 6iit.com ;

#http跳转到https
error_page 497 https://$host$uri?$args;
#include D:/phpStudy/WWW/wp1/.htaccess;

#伪静态规则
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;
}

listen 443;
server_name localhost ;

ssl on;
ssl_certificate D:/phpStudy/WWW/wp1/zs/1_6iit.com_bundle.crt;
ssl_certificate_key D:/phpStudy/WWW/wp1/zs/2_6iit.com.key;

ssl_session_timeout 5m;

ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

#charset koi8-r;

#access_log logs/host.access.log main;
root “D:/phpStudy/WWW/wp1”;
location / {
index index.html index.htm index.php l.php;
autoindex off;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME D:/phpStudy/WWW/wp1$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
# deny all;
#}
}

未经允许不得转载:流云溪|码农 » nginx服务器上wordpress的rewrite通用配置

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址