Created
October 16, 2014 07:38
-
-
Save xemoe/9794def8c89838dec090 to your computer and use it in GitHub Desktop.
Nginx sites+alias+rewrite for laravel4
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 default_server; | |
root /opt/html; | |
index index.php index.html; | |
rewrite_log on; | |
location / { | |
rewrite ^(/.*?\.php)(/.*)?$ /...$document_root/.../...$1/...$2 last; | |
} | |
set $blog_dir /opt/www/blog/public; | |
set $blog_prefix /blog; | |
set $blog_log /var/log/nginx/blog.error.log; | |
location /blog { | |
autoindex on; | |
alias $blog_dir; | |
if ( $uri !~ ^/blog/(docs|assets|robots\.txt|favicon\.ico|assets) ) { | |
rewrite ^(/blog)(/.*)?$ /...$document_root/...$blog_prefix/...$2 last; | |
} | |
error_log $blog_log notice; | |
} | |
location /... { | |
internal; | |
autoindex off; | |
location ~ ^/\.\.\.(?<p_doc_root>.*)/\.\.\.(?<p_prefix>.*)/\.\.\.(?<p_pathinfo>.*)$ { | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $p_doc_root/index.php; | |
fastcgi_param SCRIPT_NAME $p_prefix/index.php; | |
fastcgi_param REQUEST_URI $p_prefix$p_pathinfo$is_args$query_string; | |
fastcgi_param DOCUMENT_URI $p_prefix$p_pathinfo; | |
fastcgi_param DOCUMENT_ROOT $p_doc_root; | |
fastcgi_param PATH_INFO $p_pathinfo if_not_empty; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment