当我访问mywebsite.com时,我会看到我的网站。但是,当我访问mywebsite.com/page时,我得到了404。
我正在使用nginx来传送文件,根据我的阅读,我将其配置为始终进行索引,但是它似乎不起作用。
这是我的Nginx配置:
server {
listen 80 default_server;
server_name mywebsite.com;
root /var/www/mywebsite.com/frontend/build;
index index.html index.htm;
location / {
try_files $uri $uri/ index.html;
}
}
server {
listen 80;
listen [::]:80 ipv6only=on;
root /var/www/mywebsite.com/backend/public;
index index.php index.html index.htm;
server_name api.mywebsite.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我要如何使nginx与React Router配合使用?