Created
December 22, 2010 06:08
-
-
Save sparanoid/751166 to your computer and use it in GitHub Desktop.
Runing Stacey on nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name sparanoid.com www.sparanoid.com; | |
server_name_in_redirect off; | |
access_log /srv/www/sparanoid.com/logs/access.log; | |
error_log /srv/www/sparanoid.com/logs/error.log; | |
location / { | |
root /srv/www/sparanoid.com/public_html; | |
index index.php index.html index.htm; | |
# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists | |
if (!-f $request_filename){ | |
set $rule_0 1$rule_0; | |
} | |
if ($uri !~ "public/"){ | |
set $rule_0 2$rule_0; | |
} | |
if (!-f $document_root/public/$1.$2){ | |
set $rule_0 3$rule_0; | |
} | |
if ($rule_0 = "321"){ | |
rewrite /(.+)\.(html|json|xml|atom|rss|rdf|txt)$ /$1/ last; | |
} | |
# Add a trailing slash to directories | |
if (!-f $request_filename){ | |
set $rule_1 1$rule_1; | |
} | |
if (!-d $request_filename){ | |
set $rule_1 2$rule_1; | |
} | |
if ($uri !~ "(\.)"){ | |
set $rule_1 3$rule_1; | |
} | |
if ($uri !~ "(.*)/$"){ | |
set $rule_1 4$rule_1; | |
} | |
if ($rule_1 = "4321"){ | |
rewrite /([^/]+)$ /$1/ last; | |
} | |
# Rewrite any calls to /* or /app to the index.php file | |
if ($uri ~ "/app/$"){ | |
set $rule_2 1$rule_2; | |
} | |
if ($rule_2 = "1"){ | |
rewrite ^/app/ /index.php last; | |
} | |
if (!-f $request_filename){ | |
set $rule_3 1$rule_3; | |
} | |
if (!-d $request_filename){ | |
set $rule_3 2$rule_3; | |
} | |
if ($rule_3 = "21"){ | |
rewrite ^/(.*)/$ /index.php?$1 last; | |
} | |
# Rewrite any file calls to the public directory | |
if (!-f $request_filename){ | |
set $rule_4 1$rule_4; | |
} | |
if (!-d $request_filename){ | |
set $rule_4 2$rule_4; | |
} | |
if ($uri !~ "public/"){ | |
set $rule_4 3$rule_4; | |
} | |
if ($rule_4 = "321"){ | |
rewrite ^/(.+)$ /public/$1 last; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment