Heads up! This post was written 12 years ago. Some information might be outdated or may have changed since then.
server {
listen 80;
server_name "~^(?.+)\.rawpics\.net$";
if (!-d /projects/rawpics.net/$sub) {
rewrite . http://rawpics.net/ redirect;
}
root /projects/rawpics.net/$sub;
index index.php index.html index.htm;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}
location / {
try_files $uri /index.php?$args;
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php?uri=$1 last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
} Ако не намери директория просто редирекваме към главния домейн :)
ps: оказа се че повече ми харесва nginx отколкото apache :)