• Resolved palo231

    (@palo231)


    Hello,

    I configured own web page using WordPress 6.7.1 (It is running on Synology DS224+ with DSM7.2.2).
    All pages were working OK when I kept default Permalinks structure = “Plain”.

    But If I change Permalink structure = “Post name”, I have a problems:

    1. my pages are not working (all getting error 404)
    2. WP => Tools => Site Healt => shows:
      REST API Endpoint: https://pagename/wp-json/wp/v2/types/post?context=edit
      REST API Response: (404) Not Found
    3. https://pagename/wp-json gets error 404
    4. when I am trying add new page => publish, i receive error “Publishing failed. The response is not a valid JSON response.

    I do not have any .htaccess file existing in wordpress directory (where wp-config.php or index.php are located).
    I tried to save, change permalinks, resave, but no .htaccess file is created.
    I tried to create manualy this file .htaccess with following content, but didn’t help:
    # BEGIN WordPress
    RewriteEngine On RewriteBase / RewriteRule ^index.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]
    # END WordPress

    I tried restarted WebStation with PHP and Apache and nothing help…
    I was checking permissions on directory, but looks ok.
    I also disabled all plugins in WP, but this didn’t help.
    I tried to use “Redirection” plugin to fix 404 errors, but didn’t help.
    I read a lot of forums, but did not find solution…

    Could you please help how to get working my page with different Permalinks, not with “Plain”. (Is working with “Plain”).

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter palo231

    (@palo231)

    I see in Synology “Web Station” that WordPress PHP Web Service uses “Nginx” as “HTTP Backend Server”, instead of Appache 2.4. Does it mean, that it is ok that .htaccess file does not exist?

    Please, how to fix this Permalinks or JSON issue? Or what to check?

    Moderator threadi

    (@threadi)

    The .htaccess file is only taken into account for Apache web servers. For nginx web servers, a separate configuration within nginx is required. See also: https://learn.ww.wp.xz.cn/lesson/permalinks-rewriting-urls-on-apache-and-nginx/

    If the .htaccess file is not taken into account when using Apache, support for it is not activated in Apache. This configuration must be stored in the Vhost that is responsible for the website:

    AllowOverride All

    The service must then be restarted for this to take effect.

    I can’t tell you how to do this on your system. This is beyond the support we can provide here in the WordPress forum. If you have questions about the configuration of your system, contact a community that supports it.

    Thread Starter palo231

    (@palo231)

    @threadi thank you for answer. If .htaccess is not used with nginx, do you know where exactly to set “AllowOverride ALL” you mentioned (to which config file)?

    In link you provided, is also mentioned:

    On Nginx web servers, this is typically handled in the server block configuration file. Because Nginx does not support the use of an .htaccess file-like configuration on a per WordPress level, the configuration is typically added by default to the server block in a location directive.

    location / {
    try_files $uri $uri/ /index.php?$args;
    }

    Does anybody knows where to check this settings and how it should look correctly?

    Is this the same issue Permalinks not working and JSON error?

    Moderator threadi

    (@threadi)

    As mentioned above:

    I can’t tell you how to do this on your system. This is beyond the support we can provide here in the WordPress forum. If you have questions about the configuration of your system, contact a community that supports it.

    this can’t be answered here.

    Also:

    If .htaccess is not used with nginx, do you know where exactly to set “AllowOverride ALL” you mentioned (to which config file)?

    This code has to be inserted in the Apache-Vhost-configuration or the main Apache-configuration (depending on how the Apache is configured, which we do not know here).

    Thread Starter palo231

    (@palo231)

    @threadi I found this file /var/packages/Apache2.4/target/usr/local/etc/apache24/conf/httpd24.conf

    I see “AllowOverride All“. So this is OK ?

    ...

    # TODO: AllowOverride of root directory to All ??
    <Directory />
    Options FollowSymLinks
    AllowOverride All
    </Directory>

    # TODO: should apache handle this or nginx?
    <IfModule deflate_module>
    DeflateCompressionLevel 2
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    AddOutputFilter DEFLATE js css
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.[0678] no-gzip
    BrowserMatch \bMSIE\s7 !no-gzip !gzip-only-text/html
    </IfModule>

    # TODO: should apache handle this or nginx
    <Files ~ "^\.([Hh][Tt]|[Dd][Ss]_[Ss])">
    <IfModule authz_core_module>
    Require all denied
    </IfModule>
    </Files>

    <VirtualHost _default_:80 _default_:443>
    DocumentRoot "/var/services/web"
    IncludeOptional conf-enabled/alias.*.conf
    </VirtualHost>

    # TODO: Should apapche handle FileETag
    # For CVE-2003-1418
    FileETag MTime Size

    ...
    Moderator threadi

    (@threadi)

    If the directory for which it applies is the correct one, then yes. But as I said, I cannot judge that.

    Thread Starter palo231

    (@palo231)

    SUMMARY:
    When I changed Permalinks Structure from Plain to something other:

    • 404 errors on all pages
    • trying publish new page => Publishing failed. The response is not a valid JSON response.
    • Site Healt => REST API Response: (404) Not Found

    CHECKED:

    1. Check WordPress URLs in Settings – OK
    2. Fix WordPress Permalink Structure – NOT OK (works only with Plain, others error 404), no error appear when saving permalinks
    3. Regenerate WordPress .htaccess File – file not available, because of using nginx/apache
    4. View the REST API Debug Log:
      REST API Endpoint: https://myserver/wp-json/wp/v2/types/post?context=edit
      REST API Response: (404) Not Found
    5. Deactivate All WordPress Plugins – OK (no impact)
    6. Temporarily Turn Off Your Website Application Firewall – OK (no impact)
    7. Turn On Debugging in WordPress – OK (enabled, nothing in degug.log)

    Please give me an advice what to check next.

    Thread Starter palo231

    (@palo231)

    I found working solution for my issue on synology forum: https://community.synology.com/enu/forum/1/post/144749

    For DSM 7.2

    You need to find the file in the following location which contains your WordPress root directory.  

    /usr/local/etc/nginx/conf.d-available/

    for example.com file should be like as below:    

       root    "/volume1/webhost/example.com"; 

       index    index.php index.htm index.html;

    also, you will find the user.conf location of that particular file at the end.

      include /usr/local/etc/nginx/conf.d/111111-2222-333-4444/user.conf*;

    Now you need to create a new folder with a unique name and then create a user.conf file in it.

    cd /usr/local/etc/nginx/conf.d/

    mkdir 111111-2222-333-4444

    cd 111111-2222-333-4444

    sudo vi user.conf

    location / {try_files $uri $uri/ /index.php?$args;}

    save it.

    sudo synosystemctl restart nginx
Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Errors 404 after changing Permalinks structure, REST API Response 404’ is closed to new replies.