A
A
Alexander Goncharov2015-09-06 09:53:57
Nginx
Alexander Goncharov, 2015-09-06 09:53:57

How to cancel nginx redirect for images?

Good afternoon, I redirected my entire site to https using nginx:

server {
listen 80;
server_name uwebdesign.ru;
location / {
rewrite ^ https://$server_name$request_uri permanent;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

But now I need feeds, images and mp3 files to be opened via http, I can't think of a config. For feeds it worked to add this:
location ^~ /feed/ {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}

Nothing works for images and mp3 files. Please tell me what to add.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Goncharov, 2015-09-06
@websanya

location / {
if ( $request_filename !~* \.(jpg|mp3)$ ) {
rewrite ^ https://$server_name$request_uri permanent;
}
}

It was necessary to add a condition, I figured it out myself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question