Not Acceptable! An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security

Not Acceptable! An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security

  1. Blog
  2. 15 November 2026
  3. 5 min read

Stefan Bogdanescu

Founder & Senior Architect

Not Acceptable! An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security

You are looking at a classic case of Web Application Firewall (WAF) overzealousness. The message "This error was generated by Mod_Security" is your primary clue. You aren't dealing with a missing file, a broken database connection, or a PHP syntax error on the server side. Instead, you've triggered a rule in the ModSecurity engine that blocked the request because it appeared to violate security policies.

In this specific scenario involving a Moodle environment, the trigger is almost certainly related to how the browser handles image loading versus direct API calls. The user mentioned clicking on a profile picture to view registered users. When an image fails to load or behaves oddly (perhaps displaying as broken or returning a 403/429), clicking it might force the browser to make a request with specific headers or parameters that ModSecurity flags as suspicious.

The "Not Acceptable" HTTP status code (406) typically indicates that the server cannot produce a response matching the Accept headers sent by the client. However, when wrapped in a ModSecurity error, it often means the WAF dropped the request entirely before it ever reached the application logic, or it returned a custom error page configured to look like a 406/501 issue.

Understanding the Trigger

ModSecurity operates on a ruleset designed to detect SQL injection, XSS, and other attacks. It inspects both incoming requests and outgoing responses. The most common scenario for this specific error in content management systems or LMS platforms involves image handling.

When you click an image to view it directly (e.g., /dnsc/it14lms/image.php?id=...), the browser sends an Accept header like image/png, image/jpeg. If ModSecurity intercepts this and decides the request is malicious—perhaps because the URL contains a pattern resembling a path traversal attempt, or if the user agent string is missing—it will terminate the connection.

The error message "An appropriate representation... could not be found" is often a generic catch-all used by the WAF when it decides to block the resource rather than return a standard 403 Forbidden. It effectively tells the browser, "I cannot serve this image because I think it's dangerous."

Investigating the ModSecurity Logs

You cannot fix what you cannot see. The error page itself provides no context about why the rule was triggered. To resolve this, you must inspect the server logs where ModSecurity writes its audit trail.

On most Linux-based Moodle installations, these logs are found in /var/log/modsec_audit.log or sometimes within the Apache/Nginx error log if configured to append there. Look for lines containing id= followed by a number. This ID corresponds to the specific rule that fired.

Common culprits include:

  • File Path Traversal Rules: If the image URL contains parameters like ..%2f or encoded slashes, ModSecurity might block it thinking you are trying to access files outside the intended directory.
  • Sensitive File Access: Some rulesets block direct access to configuration files (.env, .git) or cache directories if the path looks similar to a user profile image path.
  • User-Agent Filtering: If the click resulted in a request without a proper User-Agent header, certain WAF configurations will drop the request immediately.

Once you identify the rule ID, you can search for it online. The OWASP ModSecurity Core Rule Set (CRS) is the most common distribution. Many rules are open to tuning. For example, if rule 942100 (often related to path traversal) is firing on a legitimate image request, you may need to adjust its sensitivity or create an exclusion.

Tuning the Ruleset

If you determine that the rule is false-positive, you have two main approaches: modifying the rule or creating an exemption.

Modifying Rule Sensitivity

If the rule is too strict for your environment, you can increase the threshold. In Apache, this might look like adding a SecRuleRemoveById directive in your .htaccess file or virtual host configuration:

# Remove the specific rule that triggered the 406 error
SecRuleRemoveById 942100

However, be cautious. Blindly removing rules can open you to attacks like directory traversal if the rule was there for a reason. A better approach is often to adjust the logic within the rule itself using SecAction or ctl:auditLogParts.

Creating Exemptions

If you need to allow specific image paths while keeping protection elsewhere, you can add an exemption at the top of your request chain:

# Allow all requests starting with the profile image path
SecRule REQUEST_URI "^/profile_images/" "id:noid,pass"

This tells ModSecurity to skip inspection for that specific prefix. This is a safer trade-off than removing the entire rule.

Configuration and Environment Variables

Sometimes the issue isn't the WAF rules themselves but how the application interacts with them. Ensure your Moodle installation is not exposing sensitive paths in URLs. If your image URLs are generating dynamic parameters that resemble attack vectors (e.g., ?file=../../../etc/passwd), ModSecurity will block them even if they are safe in context.

Check your .htaccess or Nginx configuration to ensure canonical redirects are in place and that there are no conflicting security modules interfering with image serving. If you are using a shared hosting environment where you cannot edit the main WAF ruleset, contact your host's support. They can often whitelist specific domains or paths (like joyfementira.com) after verifying the traffic is legitimate.

Final Considerations

The "Not Acceptable" error generated by ModSecurity is rarely about content negotiation in the traditional sense; it is a security block masquerading as a media type error. By inspecting the audit logs, identifying the specific rule ID, and applying targeted exemptions or sensitivity adjustments, you can restore image loading without compromising your application's security posture. Always validate changes in a staging environment first, as relaxing WAF rules can expose your Moodle instance to real threats if not done carefully.

Our network