0

I set up a redirecrt for NginX like this:

location / {
   try_files $uri $uri/ @rewrite;
}

location @rewrite {
    rewrite ^/(.*)$ /index.php?permalink=$1 last;
}

it is working fine for thousands of links but for few it does not

Some of the links which keep throwing 404 error are:

  • profile/monico
  • profile/hotstar
  • profile/jongz
  • profile/chico
  • profile/nagz
  • profile/mico
  • profile/star

For thousands of other profile/* links it works fine. I tried to access above profiles via:

index.php?permalink=profile/jongz

And it work fine. So I assume there must be some misconfiguration or something which makes nginX to throw 404 - file not found error instead of proceeding to rewrite function.

Does those links contain some characters or character combinations which prevents nginX to rewrite link correctly?

Igor Mizak
  • 101
  • 3
  • Could these URIs point to static files or directories on the server? – Richard Smith Sep 17 '19 at 09:22
  • I tried to create folder profile and file hotstar inside and it downloaded file so no 404 error. Actually google webmasters tool showed 2 new links in addition to previous: profile/jellstar, profile/az1914js – Igor Mizak Sep 23 '19 at 14:11
  • when i am looking at those links, isn't it possible that nginx is somehow looking for files with extensions ico, tar, gz? – Igor Mizak Sep 23 '19 at 14:13

1 Answers1

0

The following rule was the problem:

location ~* .(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ {
        etag on;
        if_modified_since exact;
        add_header Pragma "public";
        add_header Cache-Control "max-age=31536000, public";
}

Not sure why it is not picking dot at start of the expression. Does anyone know answer for this?

Igor Mizak
  • 101
  • 3