דפי אתר וורדפרס מציגים שגיאה "404 לא נמצא" כאשר נעשה שימוש ב-PHP-FPM של Nginx ובמצב Proxy

תסמינים

  • דפי אתר המבוססים על וורדפרס מציגים את השגיאה למטה בכל הדפים מלבד הראשי:

    404 Not Found

    מתי:
    • אפליקציית FPM המוגשת על ידי nginx מוגדרת בדומיינים > example.com > הגדרות PHP
    • מצב פרוקסי מופעל ב-  Domains  >  example.com  >  הגדרות Apache ו-nginx .
  • נקודת WordPress REST API (wp-api) מציגה שגיאה 404. ניתן לבדוק זאת על ידי גישהhttp://example.com/wp-json/wp/v2/posts

פתרון הבעיה

  1. היכנס ל- Plesk

  2. עבור אל Domains > example.com > מנהל הקבצים > httpdocs

  3. צור קובץ .htaccessהדבק את תוכן הבא:

    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

4. לחץ על כפתור שמור