在网站根目录创建文件.htaccess

文件内容如下:


Apache伪静态:

plaintext

RewriteEngine on
# Apache 2.4
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*?)([^/]*)$ $1index.php?$2 [QSA,PT,L]
# Apache other
#RewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 [L]


Nginx伪静态:

plaintext
location ~* \.(htm)$ {
    rewrite "^(.*)/(.+?).htm(.*?)$" $1/index.php?$2.htm$3 last;
}


Caddy伪静态(Caddyfile演示):

plaintext
www.yourdomain.com {
# Set this path to your site's directory.
root * /var/www
file_server
# Or serve a PHP site through php-fpm:
php_fastcgi localhost:9000
}