Nginx Tries to download file when rewriting non-existent url
Posted
by
Vince Kronlein
on Server Fault
See other posts from Server Fault
or by Vince Kronlein
Published on 2013-11-02T21:03:31Z
Indexed on
2013/11/02
21:58 UTC
Read the original article
Hit count: 310
All requests to a non-existent file should be re-written to index.php?name=$1
All other requests should be processed as normal.
With this server block, the server is trying to download all non-existent urls:
server {
server_name www.domain.com;
rewrite ^(.*) http://domain.com$1 permanent;
}
server {
listen 80;
server_name domain.com;
client_max_body_size 500M;
index index.php index.html index.htm;
root /home/username/public_html;
location ~ /\.ht {
deny all;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9002;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max;
}
location /plg {
}
location / {
if (!-f $request_filename){
rewrite ^(.*)$ /index.php?name=$1 break;
}
}
}
I've checked to see that my default_type = text/html instead of octet stream, not sure what the deal is.
© Server Fault or respective owner