Wordpress 404 no found on all pages except the homepage - php

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 443
Background 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!

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.

Related

Php HTTP redirect not working on Azure App Service

I'm trying to redirect my user to a certain website when they visit one of my end point.
https://url-shortner-in.azurewebsites.net/openfb will point to google.com
My server is hosted on Azure App Service with Slim Framework v4 using REST API.
This is my call to redirect the user.
return $response
->withHeader('Location', 'http://www.google.com')
->withStatus(302);
It's working fine on my local WAMP server. I'm getting redirected to Google.
But after uploading it on Azure App Service, the code isn't working.
I'm seeing a blank page after redirection. The URL stays the same (my website URL and not Google's.)
Is there any misconfiguration with Azure?
My .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
I suggest you choose windows platform when create webapps.
You can try to create web.config file under the wwwroot folder, if it doesn't exist. If you can find this file when deployed your webapp, you need to modify it.
The specific content to be added or modified is that RewriterConfig needs to be added to web.config.
The format is as follows:
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,URLRewriter" />
</configSections>
......
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>^default/([0-9]+)/([_0-9a-z-]+)</LookFor>
<SendTo>11.aspx?id={R:1}</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
For more details, you can refer to the following two posts:
Azure Web App Angular Not redirecting to www
DNN UrlRewrite (“DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules”) does not run custom rewrite rule on web.config
Step 1: Enable Apache .htaccess
By default, the .htaccess file is not enabled.
1. Open the default host configuration file by entering the following command in the terminal:
sudo nano /etc/apache2/sites-available/default
2. Locate the section labeled <Directory /var/www>.
In that section, change the AllowOverride None entry to all:
AllowOverride All
Save the file and exit.
3. Next, restart the Apache service:
sudo systemctl apache2 restart

Deployed new Laravel project to live server - inner page links do not work

I have recently deployed a Laravel project to my live web server via FTP (Filezilla). Inside my young1.org web root folder I have the subdomain folder bookings, which displays web content at http://bookings.young1.org. Inside that folder I have the folder, 'laravel' that contains my entire laravel application, and inside that folder there is a 'public' directory.
I have imported my local database to one of the database accounts on the live web server via phpmyadmin, and I have switched the 'DB' credentials to point to the new database inside the env file in the laravel project root (changing the following variables: DB_DATABASE, DB_USERNAME, DB_PASSWORD).
When I navigate to http://bookings.young1.org/laravel/public, the home page of my application appears, fine and dandy. However, when I click on any of the internal links (e.g. the login and register) buttons, I just get a series of blank pages, and none of the internal pages appear.
Would anyone be able to take a guess at what the problem might be?
I have tried altering the .htaccess file to look like the below, and changing my 'PATHS' variable inside public/index.php.
Thanks,
Robert
London, UK
// public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
// public/index.php
require DIR.'/../laravel/bootstrap/autoload.php';
$app = require_once DIR.'/../laravel/bootstrap/app.php';
do you have SSH on the server? if yes did u install laravel as you're supposed to, also could you include the .env file contents, you can mask out the DB username and pass and the key you had to generate
never mind my mistake, i clicked on a link and got a SQL connection error (refused)
i still need to know if you installed laravel via SSH or that you just made the public folder the root, because if that's the case laravel cant help you with that (you need a VPS and not a webhost that only supports FTP as far as i know)
and to be sure
BE CAREFULL!!!
you have SQL connection errors that show credentials
Notice that your URLs work fine if you use index.php in them, i.e.:
http://bookings.young1.org/laravel/public/index.php/register
To allow URLs without index.php the mod_rewrite module on your Apache web server must be enabled.
First try to add this line in your .htaccess file of Laravel above RewriteEngine On:
Options +FollowSymLinks
This directive is needed to enable mod_rewrite in .htaccess context.
If it doesn't work after this, then you can check if module is enabled on your web server, the easiest maybe is to paste this in the beginning of index.php in public folder:
phpinfo();
Then open any page and search for mod_rewrite on the page, and see if you can find it under Loaded Modules. If not, you have to enable it.
To do that, if you can access through SSH you can do:
sudo a2enmod rewrite
sudo service apache2 restart
For more help on enabling mod_rewrite on Apache web server, check this answer.

XMAPP - PHP - Error 400

So, this question has probably been answered before but i have changed ports in my conf files which most other posts has not. I'm suspecting this is why it won't work.
So, first i had a problem where skype was using the ports xmapp used, so i changed them to : 8080 and 4433. I also changed server name to : localhost:8080 and www.example.com:4433
When i try to go to localhost:4433 using google chrome i get :
Error 400
"Bad Request!, Your browser (or proxy) sent a request that this server could not understand."
And when i try with just localhost i get a white page.
And when i try t go to phpadmin "localhost/phpmyadmin"
it displays a white page.
Both mySql and Apache servers are running without any errors.
Any idea why and how to fix this problem? I've spent 15 hours now fixing 3 different errors.
actually you have change this port at two places in httpd.conf file,i.e
1) Listen 80
2) ServerName localhost:80
at the above places the port value should be 4433, as per your changes
Old question, but I had this error start suddenly to my XAMPP instance on WIndows 7.
It started when I was doing a cleanup and removed a folder that was referenced as a redirect in the .htaccess file.
e.g.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
If the folder public is removed/renamed, this error will start to occur, even with the simplest of PHP or HTML files being requested.
I fixed by removing the .htaccess - when I need it again I'll add it back in with the right paths.

CakePHP missing controller on EC2

I have a Cake 2.3.8 app that works fine on localhost and I uploaded it to an Ubuntu 12.04 EC2 instance, but on the index/home file I'm getting a "Missing Controller" error.
The CSS, header and footer load fine on the home/index page, but it can't seem to find the controller. Every single other page/controller of my app won't even load, I get a 404 error.
I tried this but my issue still persists.
What else should I look for that would cause it to not find the controller and not even load any other pages?
Update
I moved my contents to /var/www so it would be accessed through my-ec2-instance.com. When I go to my-ec2-instance.com/index.php the page displays (which is PagesController/home.ctp). However, anything else gives a 404 error. Modrewrite is also enabled
I can also access my actions when I reference index.php, although it displays in mobile format for whatever reason (I have a responsive template). Ex: www.my-ec2-instance.com/index.php/users/login works, although it's in a mobile format
www.my-ec2-instance.com/index.php //works
www.my-ec2-instance.com/index.php/users/login //works, but mobile format
www.my-ec2-instance.com/users/login //404 error
Please connect your instance via putty then press
sudo nano /etc/httpd/conf/httpd.conf
Check the given below line and remove the # tag
LoadModule rewrite_module modules/mod_rewrite.so
After that you can replace:
AllowOverride None
with
AllowOverride All
Note: AllowOverride None -> AllowOverride All.
From Crtl+X then press Y then press Enter (you can use this command according to your OS)
After that you can execute the command in putty
sudo service httpd restart
Then check your .htaccess file (please make sure your .htaccess should be correct) for cakePHP .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Sounds like an issue with your .htaccess file which is what would properly rewrite short URLs & handling controller routing.

What is Options +FollowSymLinks?

I am using a Lamp server on my computer. I started to use Laravel php framework.
In my .htaccess , If I use Options +FollowSymLinks , I get 500 error.
And If I comment out , I have to use index.php in my all addresses ..example:
/~ytsejam/blog/public/index.php/login
I use Arch Linux . Is there a way to solve it?
edit: I solved this by using virtual hosts. And deleting index.php from application/config/application.php in laravel folder.
You might try searching the internet for ".htaccess Options not allowed here".
A suggestion I found (using google) is:
Check to make sure that your httpd.conf file has AllowOverride All.
A .htaccess file that works for me on Mint Linux (placed in the Laravel /public folder):
# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this helps you. Otherwise you could ask a question on the Laravel forum (http://forums.laravel.com/), there are some really helpful people hanging around there.
Parameter Options FollowSymLinks enables you to have a symlink in your webroot pointing to some other file/dir. With this disabled, Apache will refuse to follow such symlink. More secure Options SymLinksIfOwnerMatch can be used instead - this will allow you to link only to other files which you do own.
If you use Options directive in .htaccess with parameter which has been forbidden in main Apache config, server will return HTTP 500 error code.
Allowed .htaccess options are defined by directive AllowOverride in the main Apache config file. To allow symlinks, this directive need to be set to All or Options.
Besides allowing use of symlinks, this directive is also needed to enable mod_rewrite in .htaccess context. But for this, also the more secure SymLinksIfOwnerMatch option can be used.
How does the server know that it should pull image.png from the /pictures folder when you visit the website and browse to the /system/files/images folder in your web browser? A so-called symbolic link is the guy that is responsible for this behavior. Somewhere in your system, there is a symlink that tells your server "If a visitor requests /system/files/images/image.png then show him /pictures/image.png."
And what is the role of the FollowSymLinks setting in this?
FollowSymLinks relates to server security. When dealing with web servers, you can't just leave things undefined. You have to tell who has access to what. The FollowSymLinks setting tells your server whether it should or should not follow symlinks. In other words, if FollowSymLinks was disabled in our case, browsing to the /system/files/images/image.png file would return depending on other settings either the 403 (access forbidden) or 404 (not found) error.
http://www.maxi-pedia.com/FollowSymLinks

Categories