SEO 的 Apache 重写规则 URL

Apache Rewrite Rules for SEO URL

我正在尝试使用 Apache mod_rewrite 进行 SEO URLS 我有以下内容:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

RewriteRule ^([^/]*)\.php$ /index.php?a= [L]
RewriteRule ^([^/]*)/([^/]*)\.php$ /index.php?a=&id= [L]

重定向到 www 和 https 的第一部分工作正常,但我需要实现以下 URL 重写但不起作用:

  1. https://www.domain.com/index.php?a=explorehttps://www.domain.com/explore/
  2. https://www.domain.com/index.php?a=page&b=abouthttps://www.domain.com/about/
  3. https://www.domain.com/index.php?a=track&id=9https://www.domain.com/track/idno
  4. https://www.domain.com/index.php?a=explore&filter=newtaghttps://www.domain.com/explore/newtag/

以下规则应该有效:

RewriteCond %{THE_REQUEST} ^GET\ /index\.php?a=(explore)(?:&filter=([^\s&]+))? [NC]
RewriteRule ^index\.php$ /%1/%2? [R=301,L,NC]

RewriteCond %{THE_REQUEST} ^GET\ /index\.php?a=(track)&id=(\d+) [NC]
RewriteRule ^index\.php$ /%1/%2/? [R=301,L,NC]

RewriteCond %{THE_REQUEST} ^GET\ /index\.php?a=page&b=about [NC]
RewriteRule ^index\.php$ /about/? [R=301,L,NC]

RewriteRule ^(explore)/(.*)/?$ /index.php?a=&filter= [L]
RewriteRule ^(track)/(\d+)/?$ /index.php?a=&id= [L]
RewriteRule ^(about)/?$ /index.php?a=page&b= [L]