location ~ /(announcements|knowledgebase|download|store|password|cart|account|subscription)(.*) { rewrite (.*) /index.php; }
location ~ /(.*)/(addons|apps|search|domains|help|services|setup|utilities|clients)(.*) { rewrite (.*) /admin/index.php;}
方案一:if (!-f $request_filename){ rewrite (.*) /index.php; }
方案二:rewrite ^/(announcements|knowledgebase|download|store|password|cart|account|subscription)(.*)$ /index.php;
其他设置:location ~* \.(tpl|inc|cfg)$ { deny all; }
location ^~ /vendor/ { deny all; }
方案一主要匹配本地没有的就丢index.php上去, 也可以用try_files
方案二主要是直接进行rewrite.
其他配置主要是隐藏一些目录和文件不让访问.
总的来说用 location来匹配稍微稳妥一些, 例如 /admin/clientsservices.php 会被为静态匹配到, 还是得运用if来判断匹配.