При конвертации через сайт
https://winginx.com/ru/htaccessOptions +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1
RewriteRule ^profile/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?page=profile&id=$1
RewriteRule ^@([A-Za-z0-9_.]+)/?$ index.php?page=profile&id=$1
RewriteRule ^@([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$ index.php?page=profile&id=$1&s=$2
RewriteRule ^administrator/editor/theme/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ administrator/editor/index.php?theme=$1&preset=$2
RewriteRule ^administrator/([A-Za-z0-9-]+)/?$ index.php?page=admin&p=$1
RewriteRule ^m_profile/([0-9]+)/([A-Za-z0-9-]+)/?$ mobile.php?page=profile&id=$1
RewriteRule ^chat/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?page=chat&id=$1
RewriteRule ^search/([A-Za-z0-9-]+)/?$ index.php?page=logout
RewriteRule ^search/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?page=logout
полученые правила после вставки в конфиг выдают ошибку: nginx: [emerg] unknown "script_filename" variable
версия nginx/1.14.2
финальный конфиг
server {
listen 80;
server_name mysite.com ;
# home directory
root /opt/WWWRoot/mysite;
charset utf-8;
index index.php index.html;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
server_tokens off;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
client_body_buffer_size 512M;
client_header_buffer_size 1k;
client_max_body_size 512M;
large_client_header_buffers 4 8k;
access_log off;
error_log /var/log/nginx/mysite.log warn;
---------
autoindex off;
location / {
if ($script_filename !~ "-d"){
rewrite ^/([A-Za-z0-9-]+)/?$ /index.php?page=$1;
}
rewrite ^/@([A-Za-z0-9_.]+)/?$ /index.php?page=profile&id=$1;
rewrite ^/@([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$ /index.php?page=profile&id=$1&s=$2;
}
location /profile {
rewrite ^/profile/([0-9]+)/([A-Za-z0-9-]+)/?$ /index.php?page=profile&id=$1;
}
location /administrator {
rewrite ^/administrator/editor/theme/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /administrator/editor/index.php?theme=$1&preset=$2;
rewrite ^/administrator/([A-Za-z0-9-]+)/?$ /index.php?page=admin&p=$1;
}
location /m_profile {
rewrite ^/m_profile/([0-9]+)/([A-Za-z0-9-]+)/?$ /mobile.php?page=profile&id=$1;
}
location /chat {
rewrite ^/chat/([0-9]+)/([A-Za-z0-9-]+)/?$ /index.php?page=chat&id=$1;
}
location /search {
rewrite ^/search/([A-Za-z0-9-]+)/?$ /index.php?page=logout;
rewrite ^/search/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /index.php?page=logout;
}
######################################################################
# -- Cache media images and turn off logging to access log
location ~ \.(gif|png|swf|js|ico|cur|css|jpg|jpeg|txt|mp3|mp4|ogg|ogv|webm|wav|ttf|woff|eot|svg)$ {
expires 30d;
add_header Cache-Control "public";
access_log off;
}
# -- Do not cache document html and data
location ~ \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
# -- Cache CSS and Javascript
location ~* \.(?:css|js)$ {
expires 2d;
add_header Cache-Control "public";
}
# -- Pass off to FastCGI processor
location ~ /\. {
deny all;
access_log off; log_not_found off;
}
# Load configuration files for the default server block.
#include /etc/nginx/default.d/.conf;
location ^~ /error/ {
internal;
root /opt/WWWRoot/mysite/;
}
location ^~ /static/ {
root /opt/WWWRoot/mysite/;
}
location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
deny all;
}
location ~ ^/(apps/) {
deny all;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; allow all; }
error_page 403 404 405 /error/404.html;
error_page 500 502 503 504 /error/500.html;
location ~ (index\.php|tiny_mce_gzip\.php)$ {
fastcgi_keep_conn on;
# for PHP-FPM over socket
gzip on;
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort on;
fastcgi_buffering on;
fastcgi_buffer_size 512m;
fastcgi_buffers 8 512m;
fastcgi_busy_buffers_size 512m;
fastcgi_temp_file_write_size 512m;
}
# -- Deny access to .htaccess files, if Apache's document root concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
Но по мануалам nginx это не совсем правильно тк дожно быть чтото типа этого
try_files $uri $uri/ /index.php?page=profile&id=$1;
Помогите написать правильные реврайты пожалуйста тк не хватает знаний ;(