Created
September 21, 2012 02:00
-
-
Save abpin/3759378 to your computer and use it in GitHub Desktop.
nginx.conf File For ExpressionEngine or Codeigniter
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 { | |
listen :80; | |
server_name www.example.com; | |
rewrite ^/(.*) http://example.com/$1 permanent; | |
} | |
server { | |
server_name example.com; | |
listen :80; | |
root /srv/www/example.com/public; | |
access_log /srv/www/example.com/logs/access.log; | |
error_log /srv/www/example.com/logs/error.log; | |
index index.html index.php; | |
location / { | |
try_files $uri $uri/ @rewrites; | |
} | |
location @rewrites { | |
rewrite ^ /index.php last; | |
} | |
if ($request_uri ~* ^(/site(/index)?|/index(.php)?)/?$) | |
{ | |
rewrite ^(.*)$ / permanent; | |
} | |
# removes trailing "index" from all controllers | |
if ($request_uri ~* index/?$) | |
{ | |
rewrite ^/(.*)/index/?$ /$1 permanent; | |
} | |
# removes trailing slashes (prevents SEO duplicate content issues) | |
if (!-d $request_filename) | |
{ | |
rewrite ^/(.+)/$ /$1 permanent; | |
} | |
# removes access to "system" folder, also allows a "System.php" controller | |
if ($request_uri ~* ^/system) | |
{ | |
rewrite ^/(.*)$ /index.php?/$1 last; | |
break; | |
} | |
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { | |
expires max; | |
add_header Pragma public; | |
add_header Cache-Control "public, must-revalidate, proxy-revalidate"; | |
} | |
location = /robots.txt { access_log off; log_not_found off; } | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location ~ /\. { access_log off; log_not_found off; deny all; } | |
location ~ \.php { | |
try_files $uri =404; | |
fastcgi_index index.php; | |
fastcgi_pass php5-fpm-sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include /etc/nginx/fastcgi_params; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment