RewriteRule ^section-([^.]+)/([^.]+)-C([^.]+)/?$ /index.php?section=$1&dossier=$2&catid=$3 [L,QSA,NC]
RewriteRule ^section-([^.]+)/?$ /index.php?section=$1 [L,QSA,NC]
RewriteRule ^([^.]+)-C([0-9]+)/?$ /index.php?section=tshirt&dossier=$1&catid=$2 [L,QSA,NC]
这条规则几乎完美地工作,除了它最后与索引不匹配 url.php。所以像这样的事情
https://www.domain.com/test-C118036/index.php?p=2&couleur=120
将导致 404 错误,但这个错误将起作用:
https://www.domain.com/test-C118036/?p=2&couleur=120
您可以在
这些规则之前添加规则以从 URI 中删除/index.php
:
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^(.+)/index'.php$ /$1 [NC]
RewriteRule ^section-([^.]+)/([^.]+)-C([^.]+)/?$ index.php?section=$1&dossier=$2&catid=$3 [L,QSA,NC]
RewriteRule ^section-([^.]+)/?$ index.php?section=$1 [L,QSA,NC]
RewriteRule ^([^.]+)-C([0-9]+)/?$ index.php?section=tshirt&dossier=$1&catid=$2 [L,QSA,NC]