Last active
December 19, 2015 21:49
-
-
Save sanguis/6023067 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { | |
server_name foo.com; | |
#root /home/sites/foo/public; | |
root /home/sites/foo/cs-bs; | |
index index.html index.htm index.php; | |
#htpasswd | |
auth_basic "Restricted"; | |
auth_basic_user_file /home/sites/foo/passwd; | |
location = / { | |
error_page 404 index.php; | |
} | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
if (!-e $request_filename) { | |
rewrite ^/(.*)$ /index.php?q=$1 last; | |
} | |
# hide protected files | |
location ~* .(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(.php)?|xtmpl)$|^(code-style.pl|Entries.*|Repository|Root|Tag|Template)$ { | |
deny all; | |
} | |
# hide backup_migrate files | |
location ~* ^/files/backup_migrate { | |
deny all; | |
} | |
# Fighting with ImageCache? This little gem is amazing. | |
location ~ ^/sites/.*/files/imagecache/ { | |
try_files $uri @rewrite; | |
} | |
# Catch image styles for D7 too. | |
location ~ ^/sites/.*/files/styles/ { | |
try_files $uri @rewrite; | |
} | |
# serve static files directly | |
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ { | |
access_log off; | |
expires 30d; | |
log_not_found off; | |
} | |
location ~* ^((?!/sites/default/files/).+\.php)$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_intercept_errors on; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
} | |
location /old_folder/ { | |
return 301 http://www.drupal.com/projects/$request_uri; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
regex for sites php parsing worked out at http://goo.gl/WCeIsD