我正在设置一个新的vps服务器nginx,php-fpm(php 7.2)。
在旧服务器上,我在.htaccess
RewriteEngine on
RewriteBase /
RewriteRule index\.html$ index.php [NC]
RewriteRule Share-(.*)\.html$ index.php?a=Share&i=$1 [NC]
RewriteRule ^news-(.*)\.html$ index.php?a=news&i=$1 [L,NC]
nginx conf
server {
listen 80;
server_name mysite.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html/mysite;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/mysite/;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
}
}
现在,它在nginx中不起作用。如何将此.htaccess转换为nginx?