A
A
askogorev2014-05-17 09:16:47
Nginx
askogorev, 2014-05-17 09:16:47

Rewrite in Nginx downloads php file when navigating through cnc

Good afternoon.
htaccess:

AddDefaultCharset UTF-8

RewriteEngine on
RewriteRule ^show/([0-9]+)/? index.php?module=show&id=$1 [L]]

Convert to nginx:
server {
  server_name example.com;
  root /home/www/example.com;
  index index.php index.html index.htm;

  location /show {
    rewrite ^/show/([0-9]+)/? "/index.php?m=show&id=$1" last;
  }

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }
}

However, when you click on the link example.com/show/1 , the browser downloads the php file. At the same time ,
the link example.com/show/1/ works fine, i.e. the slash at the end solves everything.
php-frm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
teet, 2014-05-25
@teet

can remove the slash at the end of the regular expression?

location /show {
    rewrite ^/show/([0-9]+)? "/index.php?m=show&id=$1" last;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question