Why NGINX rewrite rule is working offline but when i put it online it is not working?

server { listen xxxxxxxxxxxxx; server_name xxxxxxxx;

if ($time_iso8601 ~ “^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})”) {} access_log /home/websites/$year-$month-$day.log; error_log /home/websites/;

root /home/websites/; index index.php index.html index.htm;

location / { rewrite ^/chi-siamo/?([a-z-]+)?/?$ /chi-siamo.php?chi=$1 last; rewrite ^/categoria/?([a-z-]+)?/?([a-z0-9-]+)?/?$ /categoria.php?cat=$1&id=$2 last; rewrite ^/nazione/italia/?([0-9]+)?/?$ /nazione.php?nazione=italia&pg=$1 last; rewrite ^/nazione/italia/?([a-z0-9-]+)?/?([a-z0-9-]+)?/?$ /nazione.php?nazione=italia&regione=$1&id=$2 last; rewrite ^/nazione/?([a-z-]+)?/?([0-9-]+)?/?$ /nazione.php?nazione=$1&id=$2 last; rewrite ^/ricerca/?([a-z0-9-]+)?/?([0-9]+)?/?$ /ricerca.php?search=$1&pg=$2 last; rewrite ^(.*[^/])$ $1/ permanent; }

location ~ .php$ { root /home/websites/; fastcgi_pass; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

here is my configuration, i begging anyone to help me. Have a nice day and God bless you all :)


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @cabrerarace34

What do you mean with “working offline, but not online” ? It works on your local Nginx, but not when you put it on your droplet? What is working, what is not working?

Can you post the last 30 lines from the error log:

tail -30 /home/websites/

By the way, if is your domain, then you really need to update both Nginx and PHP, since they are very outdated, which might be the reason why you’re having problems.

PS. Please use the code button </> in the comment editor, when adding code/configurations/logs, so it keeps the formatting.