If there was an .htaccess file that has since been deleted and you're still encountering issues accessing your HTML files without any errors in the Apache logs, let's work through a few more steps to resolve the issue.
1. Verify Directory Configuration
Since you deleted the .htaccess file, ensure that your Apache configuration is still correctly allowing access to your HTML files. You should have a <Directory> directive in your site’s configuration (usually in 000-default.conf or equivalent) that looks like this:
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Ensure that AllowOverride None is set correctly so that .htaccess files do not override your main configuration, but if you want to ensure that .htaccess files are not affecting behavior, keep it as AllowOverride None.
2. Check for Other Configuration Files
Sometimes, there might be additional configuration files that could affect how Apache is handling requests for HTML files. Look in:
/etc/apache2/sites-enabled/
- Additional
.conf files in /etc/apache2/conf-enabled/ that might include configurations affecting directory access.
3. Test with a Simple HTML File
To rule out issues with specific HTML files, create a very simple HTML file directly in /var/www/html, such as:
<!-- test.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Page</title>
</head>
<body>
<h1>This is a test page!</h1>
</body>
</html>
Then access this page directly via your web browser:
http://localhost/test.html
4. Disable/Remove Other .htaccess Files
Even if you think there are no .htaccess files, do a comprehensive search to ensure none are remaining. Use the following command in the terminal:
find /var/www/html -name ".htaccess"
This checks all directories and subdirectories under /var/www/html.
5. Re-check Ownership and Permissions
Make sure that the permissions and ownership for all files and folders in the /var/www/html directory are correctly set. Use:
sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type f -exec chmod 644 {} \;
sudo find /var/www/html -type d -exec chmod 755 {} \;
6. Apache Restart
After making configuration changes or verifying files, always restart Apache to apply changes:
sudo systemctl restart apache2
7. Disable and Test Firewall
If you're running a firewall, try temporarily disabling it to see if it allows you access:
sudo ufw disable
After testing, remember to enable it again with sudo ufw enable.
8. Access from Different Browsers
Try accessing your server from different browsers or devices, including:
- Firefox
- Chrome
- Safari
- Edge
- A phone or another computer on the same network.
9. Look for Alternative Errors
Sometimes, network issues or browser add-ons might interfere with access. Try accessing via a different network if possible or without any extensions.
10. Review /etc/hosts
On the client machine, check the /etc/hosts file (only for Linux/Mac) for any incorrect mapping of localhost that might point to an unintended direction:
# Check if the following line exists:
127.0.0.1 localhost
Summary
Given that there's no error in the logs, most likely the issue is related to the configuration, permissions, or simple URL inaccuracies. Try creating a new simple HTML file, checking Apache configuration thoroughly again, and running through document permissions and ownership once more. If none of these steps resolve the issue, please provide as much detail as possible, including the exact URL you’re trying to access and the content of any other relevant configuration files. This will help isolate the issue further.