试试这个。以“#”开头的行是注释,仅用于记录命令。
<IfModule mod_rewrite.c>
# calls to initiate our requests Apache's Rewrite Module (you need this only once)
RewriteEngine on
# "If the requests does not point to an existing file"
RewriteCond %{REQUEST_FILENAME} !-f
# "If the requests does not point to an existing folder"
RewriteCond %{REQUEST_FILENAME} !-d
# "If the request contains a "2 subfolders" structure, redirects it silently to ..."
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1&secondParam=$2 [NC,QSA,L]
RewriteRule ^([^/]+)/?$ index.php?page=$1 [NC,QSA,L]
</IfModule>
试试这个版本的最后一行:
RewriteRule ^(.*)/(.*)/?$ index.php?page=$1&secondParam=$2 [NC,QSA,L]
或者
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?page=$1&secondParam=$2 [NC,QSA,L]