.htaccess и nginx
Перевел сервер на nginx. Как мне "Перенести" эти правила в nginx? Я полагаю мне нужно обновлять конфиг nginx?
RewriteBase /
RewriteEngine On
RedirectMatch 404 /.(svn|git|hg|bzr|cvs)|dump.sql(/|$)
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_URI} (dfiles/.*)
RewriteRule ^(.*)$ /dfiles.php?request=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+)$ $1 [L]
RewriteCond %{REQUEST_URI} !(jscss/.*)!(img/.*)!(image.php.*)!(video.php.*)
RewriteRule ^(.*)$ /index.php?rad_pr=1&request=$1
Ответы (1 шт):
Автор решения: Vanya228
→ Ссылка
Вот базовый конфиг для связки NGINX + PHP, не забудьте установить PHP-FPM!
server {
# Example PHP Nginx FPM config file
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to setup Nginx, PHP & PHP-FPM config
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
# pass PHP scripts on Nginx to FastCGI (PHP-FPM) server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# Nginx php-fpm sock config:
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
# Nginx php-cgi config :
# Nginx PHP fastcgi_pass 127.0.0.1:9000;
}
# deny access to Apache .htaccess on Nginx with PHP,
# if Apache and Nginx document roots concur
location ~ /\.ht {
deny all;
}
} # End of PHP FPM Nginx config example