S
S
Stok292015-11-15 13:16:36
Nginx
Stok29, 2015-11-15 13:16:36

How to mod_rewrate a site?

Good afternoon, there is .htaccess

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico)(\?|$) - [L,NC,R=404]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

it is required to do all this under nginx, generated with wnginx and inserted in this way (part from nginx.conf)
location / {

                if (!-e $request_filename){
                rewrite ^(.*)$ /index.php break;
         }

        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:9003;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }


        location @rewrite {
                rewrite ^(.*)$ /index.php break;
        }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/mysite/web/talk.mysite.ru/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/mysite/conf/web/nginx.talk.mysite.ru.conf*;
}

As a result, I get a 404 error, the site engine is IPB 4.1. How to fix this miracle? Thanks to.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mihelsonkk, 2015-11-15
@mihelsonkk

The best way is to drill into the documentation.
nginx.org/ru/docs
Try to "trace" the request
nginx.org/ru/docs/http/request_processing.html

A
Alexander, 2015-11-15
@Ky6uk-Hy6uk

I have on version 3.4 with these settings everything works fine

server {
 location / {
            try_files $uri $uri/ /index.php?q=$uri&args;
 }
location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php-fpm/ipboard.sock;
        fastcgi_index  index.php;
        fastcgi_buffers 16 8k;
        fastcgi_buffer_size 16k;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question