need help cleaning up user directory and php rules
Edho P Arief
edhoprima at gmail.com
Sat Mar 14 10:13:42 MSK 2009
Here's how I did it (got it working properly) but wonder if I can
clean it up a bit (especially about trailing slash and
/~blah/file.php)
the rewrites for user directory (not including php) are from this
http://blog.sbf5.com/?p=6
server {
listen 80;
server_name domain.tld;
root /usr/local/www/data;
index index.php;
location /~ {
if ($request_uri ~ ^/~([^/]*)(/.*[^/]|)(/*)$) {
set $homedir $1;
set $filedir $2;
set $trailingslashes $3;
rewrite ^/~([^/]*)(/|$)(.*)$ f~/$3;
}
}
location f~/ {
alias /home/$homedir/public_html/;
if (-d /home/$homedir/public_html$filedir) {
rewrite ^f~/(.*) ~/$1;
}
}
location ~/ {
#autoindex on;
alias /home/$homedir/public_html/;
if ($trailingslashes = "") {
rewrite .* /~$homedir$filedir/ redirect;
}
}
location ~ \.php$ {
if ($request_uri ~ ^/~([^/]*)(/.*)$) {
set $newroot /home/$1/public_html;
set $filedir $2;
}
if ($newroot = "") {
set $newroot /usr/local/www/data;
set $filedir $fastcgi_script_name;
}
if (!-f $newroot$filedir) {
return 404;
break;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $newroot$filedir;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
More information about the nginx
mailing list