Answer the question
In order to leave comments, you need to log in
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>
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*;
}
Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question