sruupl / batflat

Lightweight, fast and easy CMS for free. Bootstrap ready. https://batflat.org
MIT License
134 stars 54 forks source link

nginx url rewrite #25

Closed smpcasgit closed 5 years ago

smpcasgit commented 6 years ago

nginx rewrite not working! how to nginx server block rewrite?

VicDeo commented 6 years ago

Write a nginx config on your own ;)

TL;DR Disclaimer: I don't use it any more, but it worked for 1.something, feel free to adapt for newer versions

  location / {
       try_files $uri $uri/ @handler;
    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
       expires 1d;
       gzip_static on;
       etag on;
       access_log off;
    }

    location ~ \.(sdb|md|html|txt)$ {
        deny all;
    }

    location ~ /inc/data.*$ {
        deny all;
    }

    location  /admin {
        try_files $uri $uri/ /admin/index.php?$args;
    }

    location @handler {
        if (!-e $request_filename) { rewrite / /index.php last; }
        rewrite ^(.*.php)/ $1 last;
    }

    location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
        try_files $script_name index.php =404;
        fastcgi_index index.php;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param   SERVER_NAME $host;
        fastcgi_param  PATH_INFO          $path_info;
        fastcgi_read_timeout 180s;        
    }