Reputation: 99
I've got a 404 no found on all pages except the homepage in my wordpress.
It didn't make this mistake on the pre-production server, but in production. I migrated the site from preprod to prod with duplicator's plugin.
The production server is a vps ovh that I installed myself. It use letsencrypt for https. It uses a ufw firewall and openSSH and WWW Full are allowed. My apache server does not detect an error with sudo systemctl status apache2.
I've been following some topics on it, like changing the permalinks settings, when I check "Default" and save, I don't get error 404 on my other pages, it works. I noticed that in this case the content of my .htaccess file was erased. When I reset my default permalinks settings, I get the error again and I can no longer access my pages (except the homepage).
In the general settings of wordpress, the web address of wordpress is https://www.abysolutions.com and the web address of the site is https://www.abysolutions.com. In wp_options table, the values of siteurl and home are https://www.abysolutions.com.
On ovh in the area dns my domain abysolutions.com has this entry: A 146.59.234.157. However, there is no A entry for www.abysolutions.com.
Here are some configuration files :
/etc/www/apache2/sites-available/abysolutions.conf :
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName abysolutions.com
ServerAlias www.abysolutions.com
DocumentRoot /var/www/abysolutions
<Directory /var/www/abysolutions>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/abysolutions-error.log
CustomLog ${APACHE_LOG_DIR}/abysolutions-access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =abysolutions.com [OR]
RewriteCond %{SERVER_NAME} =www.abysolutions.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
This file is enabled with sudo a2ensite abysolutions.conf. I disabled default file sudo a2dissite 000-default.conf.
My .htaccess on /var/www/abysolutions : (when my permaliens settings in enabled)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I did sudo chown -R www-data:www-data /var/www/abysolutions and sudo chmod -R 755 on it.
I restarted the server with sudo systemctl reload apache2 and the rewrite mod is activated with sudo a2enmod rewrite.
I installed all the php extensions required for wordpress by following this link : https://wordpress.org/support/topic/which-php-extensions-are-needed-to-run-a-fully-operational-wordpress-site/
But it still doesn't work...
It's not the first time I install a vps and put a wordpress on it, and I always do the same steps. And then for some reason it gets stuck. The only noticeable difference I see with my previous installations is that when I migrated the site with Duplicator it offered me https://www.example.com instead of https://example.com in my previous installations. What I don't understand is why my url appears with www.
EDIT :
In the health of the site, I noticed 2 critical errors :
An active PHP session has been detected: A PHP session was created by a session_start() function call. This interferes with the REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.
and
Your site was unable to complete the closure request: Looping requests are used to launch scheduled events, and by theme and extension editors to check the stability of the code.
The loopback request on your site failed, which means that the features that rely on these requests are not currently working as they should. Error: cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received (http_request_failed)
And in the recommended improvements :
The REST API encountered an unexpected result: The REST API is one way for WordPress or other applications to communicate with the server. An example is the editor's screen, which is used to display and save your publications.
The call to the REST API returned the following unexpected result: (404) 404 Not Found Not Found
The requested URL was not found on this server.
Apache/2.4.38 (Debian) Server at www.abysolutions.com Port 443Background updates may not work properly: Unable to confirm if the wp_version_check() filter is available.
EDIT 2 :
So by comparing my .htaccess with the one of my preproduction server, I noticed that some rules added by the SimpleSSL plugin were missing. I also noticed that in my /etc/apache2/sites-available/abysolutions-le-ssl.conf file, the rules were missing.
I think it is this last solution that corrected my error. Bye!
Upvotes: 4
Views: 4261
Reputation: 1
Rami's suggestion ( https://stackoverflow.com/a/66823606/7733418 ) is so simple but works!
Additionally you might want to add this in your nginx conf file, if your wordpress files are in a subfolder and not in the html directly
server {
listen 80;
server_name localhost;
location /(your site folder) {
try_files $uri $uri/ /(your site folder)/index.php?$args;
index index.html index.htm index.php;
}
Upvotes: 0
Reputation: 559
Visit your site:
https://domain.tld/wp-admin/options-permalink.php
Click Save.
If it doesn't work, change the URL settings to Plain, click save. Then if it works, change back settings as you want.
Upvotes: 2