After checking the joomla version or trying to debug by changing the set variables and nothing worked, I have looked for htaccess file. There it was, a file '1.txt' which I've renamed to htaccess.txt and the website pages were returning the same 404 error. I have changed the file to .htaccess and the website worked.