Skip to content

Instantly share code, notes, and snippets.

@sfelde
Created July 18, 2013 00:37
Show Gist options
  • Save sfelde/6025824 to your computer and use it in GitHub Desktop.
Save sfelde/6025824 to your computer and use it in GitHub Desktop.
nginx config for twig frontend mini framework redirect
server {
server_name mdtx.dev-ms.in;
sendfile on;
root /srv/mdtx/public_html;
index index.php;
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
location /^(.+)$ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
#if (!-e $request_filename) {
#rewrite ^(.+)$ /index.php?url=$1 last; break;
#}
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args;
# Uncomment to enable naxsi on this location
#include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PATH_INFO $args;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment