nginx rewrite rule on nginx
#disallow path or file location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) { return 404; } #一键申请SSL证书验证目录相关设置 location ~ \.well-known{ allow all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log /dev/null; access_log off; } location ~ .*\.(js|css)?$ { expires 12h; error_log /dev/null; access_log off; } # SEO URL Settings # Nginx configuration of OC htaccess location = /sitemap.xml { rewrite ^(.*)$ /index.php?route=feed/google_sitemap break; } location = /googlebase.xml { rewrite ^(.*)$ /index.php?route=feed/google_base break; } location / { # This try_files directive is used to enable SEO-friendly URLs for OpenCart try_files $uri $uri/ @opencart; } location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; } # End SEO settings #https://www.cnblogs.com/firebirdweb/p/11350440.html # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS! location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ { deny all; } # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). location ~ /\. { deny all; access_log off; log_not_found off; }