Last active
December 17, 2015 00:38
-
-
Save donaldallen/5522008 to your computer and use it in GitHub Desktop.
Wildcard subdomains.
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 ~^(?<subdomain>.+?)\.domain\.com$; | |
if (!-d /usr/share/nginx/$subdomain) { | |
return http://www.domain.com/; | |
} | |
root /usr/share/nginx/$subdomain; | |
index index.html index.htm index.php; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SERVER_NAME $subdomain.domain.com; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment