.htaccess 跳过 apple-app-site-association 但过滤其他

.htaccess skip apple-app-site-association but filter other

我有一个更改扩展名的规则

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^item/(.*)/?$ item.php/ [NC,L]
RewriteRule ^([^.]+)$ .php [NC,L]

没问题但是这条规则也过滤了apple-app-site-association

需要跳过 apple-app-site-association 但过滤其他

我尝试在下面添加代码但没有成功

RewriteRule ^apple([a-z]+)$  [NC,L]
RewriteRule apple-app-site-association$  [NC,L]
RewriteRule ^apple([a-z]+)$  [NC,L,S=2]

您可以使用以下内容:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^item/(.*)/?$ item.php/ [NC,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)/?$ .php [NC,L]

上述条件确保您不会重写现有文件和文件夹。