A
A
Anton Kulyavets2017-02-04 00:41:46
PHP
Anton Kulyavets, 2017-02-04 00:41:46

VestaCP Nginx+Php-fpm how to configure rewrite?

Hello, I decided to switch from Apache to php-fpm and ran into a problem, please help.
I have my code in .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Translated to nginx as
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
}

I insert instead
location / {

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9004;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

But for some reason it doesn't work. Who can help with the correct code or am I doing something wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Verbin, 2017-02-04
@SPEC1AL1ST

Insert not instead of location, but into it
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question