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

July 18, 2017 769 views
PHP Nginx

server {
listen xxxxxxxxxxxxx;
server_name xxxxxxxx;

if ($timeiso8601 ~ “^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})”) {}
log /home/websites/gamoto.net/test/eologs/access-$year-$month-$day.log;
log /home/websites/gamoto.net/test/eo_logs/error.log;

root /home/websites/gamoto.net/test;
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/gamoto.net/test;
index index.php;
fastcgiparam SCRIPTFILENAME $documentroot$fastcgiscriptname;
include fastcgi

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

1 Answer

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/gamoto.net/test/eo_logs/error.log

By the way, if gamoto.net 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.

Have another answer? Share your knowledge.