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>
在网站根目录下新建 .htaccess
文件,将上面的代码放入保存即可,Apache根目录和子目录一样。
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; } }
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; } }