BaunCMS / Baun

A modern, lightweight, extensible CMS for PHP
https://bauncms.com
MIT License
284 stars 38 forks source link

Nginx Rewrite Rule #18

Closed ghost closed 8 years ago

ghost commented 8 years ago

What's nginx rewrite rule for this cms ? I've tried this and it did not work. All I've seen was "Baun" on blank page. try_files $uri $uri/ /index.php?$args;

damko commented 8 years ago

I had some hard time configuring nginx, mostly for the URLs like /blog

This works for me so far

index index.php;

# removes index.php from URI
if ($request_uri ~* "^(.*/)index\.php$") {
    return 301 $1;
}

# rewrites everything to /
if ( $uri !~ ^/(index.php|themes|css|images|assets|uploads|js|robots\.txt|favicon\.ico) ) {
    rewrite ^ / break;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9100;

    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include       /etc/nginx/fastcgi_params;

    fastcgi_read_timeout 3m;
}

No need to set

location / { }
ghost commented 8 years ago

Thanks, but I've chose to use Hugo instead.