今天说说Apache和Nginx伪静态设置方法和规则文件


1、Apache,需要在网站根目录 .htaccess 文件中添加以下代码


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


2、Nginx,若系统没有自带配置,那么我们需要手动配置


location / {
  try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;