mmlTools / DarkCore-CMS

This is a Trinitycore Website CMS under development
28 stars 34 forks source link

Nginx Server Rewrite for that CMS #18

Closed JustZerooo closed 7 years ago

JustZerooo commented 7 years ago

You should make an example for dummies.


server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    server_name _;

    charset utf-8;

    error_page 404 /error;

    location / {
        if (!-e $request_uri){
            rewrite ^/([^\.]+)$ /$1.php break;
        }
        if ($http_host ~* "^www\.(.+)$"){
            rewrite ^(.*)$ http://%1$request_uri redirect;
        }
        if ($request_uri ~ "-d"){
            return 403;
        }
        if ($request_uri ~ "-f"){
            return 403;
        }
    }
    location ~ \.tpl$ {
        deny all;
    }
    location ~.*\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp)\$ {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}