A WordPress website shows 404 Not Found on all pages except index.php




  • Avatar
    Tadashi Spade

    i am new to Plesk.
    my Plesk does not showing me this menu Plesk > Domains > example.com > Apache & nginx Settings 
    please help ....

  • Avatar
    Lev Iurev

    @Tadashi  this menu is available only for Plesk admin

  • Avatar
    Jeff Carter

    My nginx config analysis warns that the prescribed replacement:

    location ~ / {
    index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
    try_files $uri $uri/ /index.php?$args;

    Does not have an ideal regex pattern.....

    "Regex location has no regex pattern
    Regex location has a valid modifier, but does not have a regex pattern.
    Performance-wise it is more efficient to configure exact or prefix matching for locations that do not require regex matching. It is also less prone to errors. Please refer to the documentation describing location directive to learn more."

    "Regex location has no anchors in regex pattern
    Regex location has a regex pattern without ^ or $. This is a configuration style that is prone to errors. It may also lead to a situation when requests partially matching the regex pattern are incorrectly routed to this location.
    Always use ^ or $ achor in a regex pattern."

    Given this advice, should that location directive be modified?




  • Avatar
    Robert Asilbekov

    @Jeff  As far as I understand analyzer does not like ~ in location. According to nginx docs "...the “~” modifier (for case-sensitive matching). To find location matching a given request, nginx first checks locations defined using the prefix strings (prefix locations)."

    You may remove "~" it should not affect performance. As for other options, I see no problems. Moreover, the same sample is provided by Nginx and WordPress. However, it would be great if you may suggest a better option to build an ideal regex.


  • Avatar
    Jeff Carter

    Yes, my question really boils down to which new configuration the article should advise:

    1. location / {

    (Which essentially removes the regex)


    2. location ~ /$ {

    (Which correctly anchors the general regex pattern)

    It does seem that the WordPress Codex recommends #1.  Is there agreement then?

  • Avatar
    Jeff Carter

    My testing shows that #2 is correct.

  • Avatar
    Konstantin Annikov


    Yes, you are right here. 

    Thank you for the input. 

Please sign in to leave a comment.

Have more questions? Submit a request