til-schneider / slim-wiki

A slim wiki based on PHP and markdown
MIT License
13 stars 7 forks source link

ngnix rewrite #11

Closed abbychau closed 6 years ago

abbychau commented 7 years ago

what is the rewrite for nginx?

til-schneider commented 7 years ago

The current .htaccess is:

RewriteEngine On

RewriteCond %{THE_REQUEST} !^GET\ .*?/client/([a-z]\.(js|css)|img/|libs/)
RewriteCond %{THE_REQUEST} !^GET\ .*?/server/theme/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]

The nginx equivalent could be (not tested):

set $use_rewrite 1;
if ($request ~ "^GET .*?/client/([a-z]\.(js|css)|img/|libs/)") {
    set $use_rewrite 0;
}
if ($request ~ "^GET .*?/server/theme/") {
    set $use_rewrite 0;
}
if (-f $request_filename) {
    set $use_rewrite 0;
}
if (-d $request_filename) {
    set $use_rewrite 0;
}

if ($use_rewrite = 1) {
    rewrite ^(.*)$ /index.php break;
}