0

I honestly did expect to get here...
I tried every tool in the book...
Save changes on the permalinks page...
I installed debug this to see what going on with the query...
I repeated other operations and changes to configurations but of no avail.
I've spent hours reading on .htaccess params as well as nginx server block configurations...nothing worx.
My menu keeps on giving 404 unless I set permalinks to plain.
I am on linode VPS, ubuntu 14.04 + LEMP stack
Here are my .htaccess & my site's configs...

.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

<Files 403.shtml>
order allow,deny
allow from all
</Files>

# Leverage Browser Caching Ninja -- Starts here
<IfModule mod_expires.c>
ExpiresActive On 
ExpiresDefault "access plus 1 month" 
ExpiresByType image/x-icon "access plus 1 year" 
ExpiresByType image/gif "access plus 1 month" 
ExpiresByType image/png "access plus 1 month" 
ExpiresByType image/jpg "access plus 1 month" 
ExpiresByType image/jpeg "access plus 1 month" 
ExpiresByType text/css "access 1 month" 
ExpiresByType application/javascript "access plus 1 year" 
</IfModule> 
# Leverage Browser Caching Ninja -- Ends here


# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

nginx server block

server {
        server_name www.xxx.com xxx.com;
        root /home/alma/xxx.com;
        index index.php;
        include global/restrictions.conf;
        include global/wordpress_xxx.conf;
        error_log /var/log/nginx/xxx_error.log;
        access_log /var/log/nginx/xxx_access.log;
}

global/wordpress_xxx.conf

# http://wiki.nginx.org/HttpCoreModule
location / {
    #try_files $uri $uri/ /index.php?$args;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
}

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#   fastcgi_intercept_errors on;
    fastcgi_param PHP_VALUE "upload_max_filesize = 16M \n post_max_size=18M";
    client_max_body_size 68M;
    include fastcgi_params;
}

location ~ ^/(wp-admin|wp-login\.php) {
        auth_basic "Welcome - Admin Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
}

location = /wp-login.php {
    deny all;

    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PHP_VALUE "upload_max_filesize = 16M \n post_max_size=18M";
    client_max_body_size 68M;
}

global/restrictions.conf

# Global restrictions configuration file.
location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

location ~ /\. {
    deny all;
}

location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
}

These all worked prior to the last update...
Has anyone encountered such an issue? Does anyone know how to resolve this? Is there something in my configuration that might be causing the issue after the update to 4.8?
Thanx

P.s. the error logs are not showing anything in particular...

  • Try removing the <IfModule mod_rewrite.c> wrapper - do you get an error? You appear to employing a "WordPress" front controller in both the Nginx config file and .htaccess? Why both? Your .htaccess file contains an exception for 403.shtml - but this isn't referenced in the config files shown here? – MrWhite Jul 22 '17 at 21:44
0

You might try flush_rewrite_rules( $hard ); Be sure to remove the function aftewards though.

https://codex.wordpress.org/Function_Reference/flush_rewrite_rules

0

I've ran into that trouble before with some of my sites when I transferred them to another server.

Here's what I did. edit your apache2.conf at /etc/apache2/ folder.

Run the following command:

nano /etc/apache2/apache2.conf

Scroll down and look for this section with a comment:

# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.

Make sure that this is the one in there:

<Directory /var/www/>
  Options Indexes FollowSymLinks
  AllowOverride all
  Require all granted
</Directory>

For short, grant it. For your permalinks not to fail.

-Dave

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.