WEB运维手册

伪静态规则

Wordpress

apache

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

nginx

##第一种方法,虽然简单,但location中还有rewrite,会出现问题。
location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
    }

##第二种方法
location / {
    if (-d wp-admin){
        break;
    }
    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;
    }
}

emlog

apache

官方支持伪静态,设置后自动生成。

nginx

location / { 
    if (!-e $request_filename) { 
        rewrite ^/(.+)$ /index.php last; 
    }
}

typecho

apache

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L]

nginx

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