zoukankan      html  css  js  c++  java
  • Nginx下WordPress的Rewrite

    Nginx下WordPress的Rewrite

    Nginx下WordPress的Rewrite
    Apache
    在Apache下,利用mod_rewrite来实现URL的静态化。

    .htaccess的内容如下:
    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    Nginx
    在上次《Nginx的Rewrite配置》中有个朋友问WordPress如何配置Rewrite,当时也没给个完整正确的答案,最近自己需要Nginx下配置,不得不去解决这个问题。

    其实在Nginx下配置WordPress的Rewrite还是比较简单的,在location /{………………}里面加入
    if (!-f $request_filename){
    rewrite (.*) /index.php;
    }
    即可实现。

    下面是一个完整的vhost的配置文件
    server {
    listen 80;
    server_name ccvita.com ww.ccvita.com;
    location / {
            index index.html index.htm index.php;
            root /www/wwwroot/ccvita.com;
            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 ~ \.php$ {
            include fastcgi_params;
            fastcgi_index index.php;
            fastcgi_pass 127.0.0.1:8787;
            fastcgi_param SCRIPT_FILENAME /www/wwwroot/ccvita.com$fastcgi_script_name;
            }
    location /ccvita-status {
            stub_status on;
            access_log off;
            }
    }
  • 相关阅读:
    php实现cookie加密解密
    三个php加密解密算法
    一个经典的PHP加密解密算法
    Webpack 核心模块 tapable 解析(转)
    详解基于vue,vue-router, vuex以及addRoutes进行权限控制
    编写一个插件
    详解css3 pointer-events(阻止hover、active、onclick等触发事件来
    Dockerfile HEALTHCHECK详解
    Dockerfile 指令 WORKDIR介绍
    NPM私有包部署到私有仓库
  • 原文地址:https://www.cnblogs.com/top5/p/1457917.html
Copyright © 2011-2022 走看看